I am working on a Web App, coded in VB.net

Here is some code and I'll explain it, Hope I use the code tags properly

<asp:LoginView ID="LoginView1" runat="server">
   <LoggedInTemplate>
   Only Logged in users can see this
   <asp:LinkButton ID="LinkButton1" runat="server"/>
   <!-- This is a Rich Text Editor -->
    <FTB:FreeTextBox id="FTB1" Width="600px" OnSaveClick="FTB1_SaveClick" runat="Server" ToolbarLayout="ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu, FontForeColorPicker, FontBackColorsMenu,  RemoveFormat,Save, " ToolbarStyleConfiguration="OfficeXP"  >
    </FTB:FreeTextBox>
    <br />  
     </LoggedInTemplate>
   <AnonymousTemplate>
   Anonymous can see this   
   </AnonymousTemplate>
    </asp:LoginView>
   <pre>  <asp:Label ID="lblText" runat="server" Text=""></asp:Label> </pre>

lblText is passed the ftb1.text information in the .vb file here:

Public Sub FTB1_SaveClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FTB1.SaveClick
        lblText.Text = Me.FTB1.Text
    End Sub

When I run this code and attempt to execute the FTB1_SaveClick, I get a NullReferenceException on this line "lblText.Text = Me.FTB1.Text"

The weird part is if I take the FTB control out of the LoginView completely, it works perfect. Anyone see anything blatant?

I am working on a Web App, coded in VB.net

Here is some code and I'll explain it, Hope I use the code tags properly

<asp:LoginView ID="LoginView1" runat="server">
   <LoggedInTemplate>
   Only Logged in users can see this
   <asp:LinkButton ID="LinkButton1" runat="server"/>
   <!-- This is a Rich Text Editor -->
    <FTB:FreeTextBox id="FTB1" Width="600px" OnSaveClick="FTB1_SaveClick" runat="Server" ToolbarLayout="ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu, FontForeColorPicker, FontBackColorsMenu,  RemoveFormat,Save, " ToolbarStyleConfiguration="OfficeXP"  >
    </FTB:FreeTextBox>
    <br />  
     </LoggedInTemplate>
   <AnonymousTemplate>
   Anonymous can see this   
   </AnonymousTemplate>
    </asp:LoginView>
   <pre>  <asp:Label ID="lblText" runat="server" Text=""></asp:Label> </pre>

lblText is passed the ftb1.text information in the .vb file here:

Public Sub FTB1_SaveClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FTB1.SaveClick
        lblText.Text = Me.FTB1.Text
    End Sub

When I run this code and attempt to execute the FTB1_SaveClick, I get a NullReferenceException on this line "lblText.Text = Me.FTB1.Text"

The weird part is if I take the FTB control out of the LoginView completely, it works perfect. Anyone see anything blatant?

hi

You cant assign directly from an embeded control value or other property. Use the following code to solve your problem

Dim txt As FreeTextBox 
        txt = CType(LoginView1.FindControl("FTB1"), FreeTextBox )
if not isnothing(txt) then
      '//Do your stuff here
end if

MARK AS SOLVED IF IT HELPS YOU!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.