Page.FindControl not working on ASCX

  • Thread starter Thread starter Michael Murschell
  • Start date Start date
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?
 
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
 
Back
Top