Control ID's

J

Jill Graham

Hi,

My web page loads the controls dynamically using
Page.LoadControl("~/myControls/myControl.ascx")

The control myControl.ascx contains several controls with following ID's :
"_content1", "_content2", "_content3", ...

Once the control myControl.ascx has been loaded into the web page, the ID's
have been changed : "_ctl0:_content1", "_ctl1:_content2", ...
and the method Page.FindControl("_control1") returns nothing !

Does anybody know how I can continu to use the Page.FindControl method ?

Jill
 
S

Sam

My web page loads the controls dynamically using
Page.LoadControl("~/myControls/myControl.ascx")

So you're doing:
1) Control loadedControl =
Page.LoadControl("~/myControls/myControl.ascx")

and then 2) Page.Controls.Add(loadedControl)?

I believe you have to do loadedControl.FindControl("content1") for it
to work, or alternatively
Page.FindControl("userControlID").FindControl("content1") where you've
set loadedControl.ID = "userControlID" explicitly as an extra step
between steps 1) and 2) above.

-Sam
 

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

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top