problem with FindControl

T

Terry

Hi,

i want to access control "TextBox1" embedded in another control "LoginView1"
in order to change the 'Text' of the textbox.

Therefore i use 'FindControl' method but i get error:
"Object reference not set to an instance of an object" on line: tb =
lv.FindControl("textbox1")


Thanks for help
Cliff


aspx:
----
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<table>
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<fieldset style="height: 425px; width: 335px;">
<tr><td>
<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
</td></tr>
</fieldset>
</LoggedInTemplate>
</asp:LoginView>
</table>
</asp:Content>

code-behind:
-----------
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim lv As LoginView
Dim tb As TextBox
lv = FindControl("loginview1")
tb = lv.FindControl("textbox1")
tb.Text = "ok"
end sub
 
T

Teemu Keiski

If you are running this on the content page, you don't need tom FindControl
the LoginView. You can just

Dim tb As TextBox
tb = Me.LoginView1.FindControl("textbox1")
tb.Text = "ok"
 
T

Terry

Thanks, it works indeed ...
Maybe you can also help me with the other problem in the thread above "how
to trigger .."?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top