Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My webpage has master page. Im using update panel also. I clear the textbox using following method.

C#
ContentPlaceHolder content = pageControl.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
 cl = pageControl.Master.FindControl("ContentPlaceHolder1");
  
                foreach (Control ct in cl.Controls)
                {
                    if (ControlType.TextBox == controlName)
                    {
                        string gtype=ct.GetType().ToString();
                        if (ct.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                           pageControl.Master.FindControl("ContentPlaceHolder1"); = string.Empty;
                    }
}


It is working without update panel. But in Update panel it is not working. No error come. It is execute this coding. But the textbox is not cleared.
Posted

Try this,

If the UpdateMode property is set to Conditional
You call the Update method(UpdatePanel.UpdateMode() Property) of the UpdatePanel.
 
Share this answer
 
v2
following Code will help you to come out from your problem

XML
IEnumerable<TextBox> textBoxes = panel.Controls.GetChildControls().OfType<TextBox>();
foreach (TextBox tb in textBoxes)
{
    tb.Text = "";
}
 
Share this answer
 
Comments
UshaCbe 17-Jul-13 4:18am    
Hi thanks for your kind reply. I try this one. But It shows Error on GetChildControls.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900