Page.FindControl not working on ASCX

M

Michael Murschell

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?
 
M

matt

Depends where the control is you are trying to find...

If you are trying to find a control in the parent page, you would use
Parent.Page.FindControl("controlID");

If you are trying to find a control within the user control's own control
collection then you would use
this.FindControl("controlID");

Not quite sure what Page.FindControl does when called from within a
UserControl but it never seems to be of any use as it always returns null.
Use the above methods and you should find the control you're looking for.

Matt
http://www.3internet.co.uk
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top