Refer to Form on page from user control

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

I have a form, "Form1" that I would normally step through using

Control frm = FindControl("Form1");
foreach(Control ctrl in frm.Controls)

But now I have this page as a user control loaded by a handler that has menu
bars etc on. Form1 now resides on this handler page.

How do I now use the same reference inside my user control to page through
the controls on the form in the main page?

From the main page I can look at usercontrol controls, but not vice versa.


Cheers!
Simon
 
Simon said:
I have a form, "Form1" that I would normally step through using

Control frm = FindControl("Form1");
foreach(Control ctrl in frm.Controls)

But now I have this page as a user control loaded by a handler that
has menu bars etc on. Form1 now resides on this handler page.

How do I now use the same reference inside my user control to page
through the controls on the form in the main page?


For anyone Googling this my attempts were wrong because I read off the trace
in the wrong order! Just use

Control ctrl =
Page.FindControl("Form1").FindControl("phContent").FindControl("_ctl0");

for each control in ctrl.controls....
 
Back
Top