473,624 Members | 2,346 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" ContentPlaceHol derID="ContentP laceHolder1"
Runat="Server">
<table>
<asp:LoginVie w ID="LoginView1 " runat="server">
<LoggedInTempla te>
<fieldset style="height: 425px; width: 335px;">
<tr><td>
<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
</td></tr>
</fieldset>
</LoggedInTemplat e>
</asp:LoginView>
</table>
</asp:Content>

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

Feb 15 '07 #1
2 5892
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.F indControl("tex tbox1")
tb.Text = "ok"

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

"Terry" <no@mail.prwrot e in message
news:eU******** ******@TK2MSFTN GP04.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" ContentPlaceHol derID="ContentP laceHolder1"
Runat="Server">
<table>
<asp:LoginVie w ID="LoginView1 " runat="server">
<LoggedInTempla te>
<fieldset style="height: 425px; width: 335px;">
<tr><td>
<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
</td></tr>
</fieldset>
</LoggedInTemplat e>
</asp:LoginView>
</table>
</asp:Content>

code-behind:
-----------
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
Dim lv As LoginView
Dim tb As TextBox
lv = FindControl("lo ginview1")
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****@aspalli ance.comschreef in bericht
news:F7******** *************** ***********@mic rosoft.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.F indControl("tex tbox1")
tb.Text = "ok"

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

"Terry" <no@mail.prwrot e in message
news:eU******** ******@TK2MSFTN GP04.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" ContentPlaceHol derID="ContentP laceHolder1"
Runat="Server" >
<table>
<asp:LoginVi ew ID="LoginView1 " runat="server">
<LoggedInTempl ate>
<fieldset style="height: 425px; width: 335px;">
<tr><td>
<asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox>
</td></tr>
</fieldset>
</LoggedInTemplat e>
</asp:LoginView>
</table>
</asp:Content>

code-behind:
-----------
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventAr gs) Handles Me.Load
Dim lv As LoginView
Dim tb As TextBox
lv = FindControl("lo ginview1")
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
2260
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 button_click function because the only way to find the listbox is: (listbox)e.item.findcontrol What s the solution to this problem?
4
2088
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. Each question is displayed and answered, then result written to a SQL table. Then the next question is read from a table and displayed using the load_page event again. The questions display and function perfectly. The user anwers the question...
3
1140
by: Savas Ates | last post by:
It is in my <EditItemTemplateTag.. <asp:DropDownList Runat=server ID="CIdeefixeSatis" SelectedIndex='<%# SelectMyIndex(DataBinder.Eval(Container, "DataItem.ideefixesatis")) %>' <asp:ListItem Value="True">Stokta Var</asp:ListItem>
0
2395
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 View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
3
1541
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 error is thrown about getting the data. If I go in and make a change to the .cs file, the application runs fine. The change I make is like insert a space somewhere just to make the file recompile and it works again. What causes this? It...
8
1497
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;"> <asp:Label ID="Label1" runat="server"></asp:Label> <iframe ..... ></iframe> <textarea id="txta" rows="6"></textarea>
2
2627
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 update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also updating the first record of the table in the sql database every time. No error messages are on...
4
8547
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 when it displays it shows values from the database and i have a link button edit on the ItemTemplate that changes the mode to edit mode and allows to edit the values which can be edited...
2
6936
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 and i am implementing it in my website....
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8334
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.