473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with FindControl

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

Feb 15 '07 #1
2 5883
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"

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Terry" <no@mail.prwrote in message
news:eU**************@TK2MSFTNGP04.phx.gbl...
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
Feb 15 '07 #2
Thanks, it works indeed ...
Maybe you can also help me with the other problem in the thread above "how
to trigger .."?

"Teemu Keiski" <jo****@aspalliance.comschreef in bericht
news:F7**********************************@microsof t.com...
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"

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Terry" <no@mail.prwrote in message
news:eU**************@TK2MSFTNGP04.phx.gbl...
>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

Feb 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2253
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
4
2073
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
3
1133
by: Savas Ates | last post by:
It is in my <EditItemTemplateTag.. <asp:DropDownList Runat=server ID="CIdeefixeSatis" SelectedIndex='<%# SelectMyIndex(DataBinder.Eval(Container, "DataItem.ideefixesatis")) %>' ...
0
2385
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
3
1529
by: =?Utf-8?B?dmluY2VudHc1Ng==?= | last post by:
I have an ASP.NET 2.0 application. It is pretty basic. What it does is shows a gridview of data from a stored procedure. The user can also select a date filter. The problem is that sometimes an...
8
1492
by: Chris | last post by:
Hi, i have in an content page a fieldset containing a label, an iframe and a textarea: <asp:Content ID="Content1" ContentPlaceHolderID="main" Runat="Server"> <fieldset style="width:650px;">...
2
2610
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
4
8533
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
2
6922
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.