Hello When we have some 30 textboxes in a page where it has a master Page. If we want to erase all th data  in textboxes usuallywe will write TextBox1.Text==” “; But it s time consuming so I have the easy way to do it.    wait…….

private void getAllCtl(ControlCollection ctls)
{
foreach (Control c in ctls)
{
if (c is System.Web.UI.WebControls.TextBox)
{
TextBox txt = c as TextBox;
txt.Text = “”;

}
if (c.HasControls())
{
getAllCtl(c.Controls);

}
}
}

In the button code event please write to recognize contentplaceholder in masterpage

ContentPlaceHolder ContentPlaceHolder1=this.Master.FindControl(“ContentPlaceHolder1”) as ContentPlaceHolder;
getAllCtl(ContentPlaceHolder1.Controls);

Advertisement