asp. net initializes a small example of a text box

  • 2020-06-15 08:01:37
  • OfStack


private void ClearAllText(System.Web.UI.Control contrl)
  {
      int ctl_count=contrl.Controls.Count;
   for (int i=0;i<ctl_count;i ) 
   {
    foreach(Control ctl in contrl.Controls[i].Controls)
    {
     if (ctl.HasControls())
     {
      ClearAllText(ctl.Parent);
     }
     else
     {
      if (ctl is TextBox)
       (ctl as TextBox).Text="";
     }
    }
   }
  }

Add 1 button to the page and call this function with this. Page as follows:

ClearAllText(this.Page);

The above code is only for learning, I hope to help you.

Related articles: