Finding controls thru iteration in asp.net 2.0
This example shows how to find control from a page which is inside a master page.
public void FindControls(ControlCollection ctlCollection)
{
foreach (Control ctl in ctlCollection)
{
if (ctl.ID == "TextBox")
{
//... some code here
}
}
}
and add the following code in your page (which is inside master page).
ContentPlaceHolder cph = (ContentPlaceHolder)this.Form.FindControl("ContentPlaceHolder1");
findControls(cph.Controls);
public void FindControls(ControlCollection ctlCollection)
{
foreach (Control ctl in ctlCollection)
{
if (ctl.ID == "TextBox")
{
//... some code here
}
}
}
and add the following code in your page (which is inside master page).
ContentPlaceHolder cph = (ContentPlaceHolder)this.Form.FindControl("ContentPlaceHolder1");
findControls(cph.Controls);
Comments