0

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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

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!!!

Edited by reach_yousuf: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.