void EmptyTextBox(ControlCollection cc)
        {
            for (int i = 0; i < cc.Count; i++)
            {
                if (cc[i].GetType() == typeof(TextBox))
                {
                    ((TextBox)cc[i]).Text = string.Empty;
                }
                if (cc[i].HasControls())
                {
                    EmptyTextBox(cc[i].Controls);
                }
            }
        }

 

调用EmptyTextBox(this.Page.Controls);

 

Code 2:

            foreach (Control control in this.Form.Controls)
            {
                if (control is System.Web.UI.WebControls.TextBox)
                {
                    TextBox txt = (TextBox)control;
                    txt.Text = string.Empty;
                }
            }

 


相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2021-11-23
  • 2021-12-08
  • 2021-11-21
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-01-31
相关资源
相似解决方案