/// <summary>
    /// 遍历页面上所有控件
    /// </summary>
    /// <param name="page">指定的Page</param>
    /// <param name="flag">false-不可用,true-可用</param>

    public void ControlReadOnly(System.Web.UI.Control page, bool flag)
    {
        int nPageControls = page.Controls.Count;
        for (int i = 0; i < nPageControls; i++)
        {
            foreach (System.Web.UI.Control control in page.Controls[i].Controls)
            {
                if (control is TextBox)
                    (control as TextBox).Enabled = flag;
                if (control is DropDownList)
                    (control as DropDownList).Enabled = flag;
            }
        }
    }
    /// <summary>
    /// 将文本框置空
    /// </summary>
    public void ClearAll(System.Web.UI.Control page)
    {
        int nPageControls = page.Controls.Count;
        for (int i = 0; i < nPageControls; i++)
        {
            foreach (System.Web.UI.Control control in page.Controls[i].Controls)
            {
                if (control is TextBox)
                    (control as TextBox).Text = "";
                if (control is Label)
                    (control as Label).Text = "";
            }
        }
    }

 

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2021-12-29
  • 2021-07-20
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
猜你喜欢
  • 2021-11-23
  • 2021-08-29
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
相关资源
相似解决方案