473,671 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FindControl not working in v2 after conversion from 1.1

I have a web page that makes extensive use of FindControl in the Page.Load
event to dynamicly populate label controls. Worked fine in 1.1 but I get a
"object not set to an instance...or not found" kind of message.

ex,
CType(FindContr ol("FY" & istring & "PayLabel") ,
System.Web.UI.W ebControls.Labe l).Text = YearString

Another difference is that in 1.1 I used a UserControl for a menu and in v2
I am using Master Pages.

Is there something I can do to retrieve this functionality? The v1.1 code is
really useful. I would hate to have to redo it...

Thanks
--
Brad

"Software is like melted pudding..."
Nov 9 '06 #1
3 1115
Hi,

Brad Roberts wrote:
I have a web page that makes extensive use of FindControl in the Page.Load
event to dynamicly populate label controls. Worked fine in 1.1 but I get a
"object not set to an instance...or not found" kind of message.

ex,
CType(FindContr ol("FY" & istring & "PayLabel") ,
System.Web.UI.W ebControls.Labe l).Text = YearString

Another difference is that in 1.1 I used a UserControl for a menu and in v2
I am using Master Pages.

Is there something I can do to retrieve this functionality? The v1.1 code is
really useful. I would hate to have to redo it...
is the control that is causing the problem contained within another control
(i.e., a panel)? You might have to do a recursive loop to also search
controls that themselves host other controls.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 10 '06 #2
The web page has a master page with a content page. The Master page contains
a ASP.NET menu control and some images. The content is separate. The controls
that I am trying to access are standard label and textbox controls(runat =
server).

It worked fine with 1.1...

--
Brad

"Software is like melted pudding..."
"Olaf Rabbachin" wrote:
Hi,

Brad Roberts wrote:
I have a web page that makes extensive use of FindControl in the Page.Load
event to dynamicly populate label controls. Worked fine in 1.1 but I get a
"object not set to an instance...or not found" kind of message.

ex,
CType(FindContr ol("FY" & istring & "PayLabel") ,
System.Web.UI.W ebControls.Labe l).Text = YearString

Another difference is that in 1.1 I used a UserControl for a menu and in v2
I am using Master Pages.

Is there something I can do to retrieve this functionality? The v1.1 code is
really useful. I would hate to have to redo it...

is the control that is causing the problem contained within another control
(i.e., a panel)? You might have to do a recursive loop to also search
controls that themselves host other controls.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 13 '06 #3
Found it. I just did not search as well as I should have.

http://msdn2.microsoft.com/en-us/library/xxwa0ff0.aspx

--
Brad

"Software is like melted pudding..."
"Brad Roberts" wrote:
The web page has a master page with a content page. The Master page contains
a ASP.NET menu control and some images. The content is separate. The controls
that I am trying to access are standard label and textbox controls(runat =
server).

It worked fine with 1.1...

--
Brad

"Software is like melted pudding..."
"Olaf Rabbachin" wrote:
Hi,

Brad Roberts wrote:
I have a web page that makes extensive use of FindControl in the Page.Load
event to dynamicly populate label controls. Worked fine in 1.1 but I get a
"object not set to an instance...or not found" kind of message.
>
ex,
CType(FindContr ol("FY" & istring & "PayLabel") ,
System.Web.UI.W ebControls.Labe l).Text = YearString
>
Another difference is that in 1.1 I used a UserControl for a menu and in v2
I am using Master Pages.
>
Is there something I can do to retrieve this functionality? The v1.1 code is
really useful. I would hate to have to redo it...
is the control that is causing the problem contained within another control
(i.e., a panel)? You might have to do a recursive loop to also search
controls that themselves host other controls.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 13 '06 #4

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

Similar topics

1
1284
by: Ivan Demkovitch | last post by:
Hi! I have following problem: When I create control dynamically and assign ID to it it get's changed if you look at output HTML. Because I add this control inside ascx it is prefixed with something like "ctl0_". Therefore FindControl is not working...
1
12055
by: Michael Murschell | last post by:
If I call Page.FindControl() on an aspx, it finds the control, but if I call it on an ASCX, it does not. Why not? And how would I call it?
1
1897
by: tshad | last post by:
I am using sample code from C# and am trying to convert it to VB.Net in my aspx page. This works in C#: DataGrid oGrid = (DataGrid)oItem.FindControl("DataGrid1"); I have tried all kinds of combinations trying to get it to work: ***********************************************************************
10
1900
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain column that I need to populate while in Edit Mode. Two questions: Is there a way to directly use another DropDownList as a DataSource? If so how? I'm using the following code to try to populate the DropDownList, but
2
1951
by: sck10 | last post by:
Hello, I am trying to get the value of a control in a FormView. In vb, I would use the following: e.NewValues("ServiceIdeaQ01") = CType(this.fvServiceIdea.FindControl("lblServiceIdeaQ01Edit"), Label).Text For c#, what I have found on the web is the following:
5
1813
by: daniel.hedz | last post by:
I am generating a usercontrol dynamically successfully, but when I try to find that usercontrol I get a type mismatch. This is what I am doing: //Loading my usercontrol MyWebApp.Folder.Folder.MyUsercontrol myUC = (MyWebApp.Folder.Folder.MyUsercontrol) LoadControl("~/Folder/Folder/MyUsercontrol.ascx");
14
3194
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of that control on a Page ("Defaul.aspx"). The control works fine. Now, I want to be able to use "FindControl()" from within my Default.aspx as follows: MyUC C = (MyUC)this.FindControl("SomeID"); When I try to run this, I get error: "The type or namespace name 'MyUC' could not be found (are you missing a
7
5691
by: AAaron123 | last post by:
Me.FindControl("MissionScheduleID"), below returns null. Do you know what I'm doing wrong? Thanks ***In my .aspx file I have: asp:Content ID="Content3" contentplaceholderid="MainMasterLeftDataID" runat="server">
9
2182
by: AAaron123 | last post by:
I'm this far in determining the correct code to find a textbox I need to set. Me.Master.FindControl("Body1").FindControl("Form2").FindControl("Table2").FindControl("TableRow7").FindControl("TableCellR7C2S2").FindControl("RightCPH").FindControl("div1").FindControl("div2").FindControl("LoginView1") Took me longer than I want to say to produce the above and I'm not there yet.
0
8927
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...
0
8825
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7445
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
6237
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
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
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
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
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.