zoukankan      html  css  js  c++  java
  • 编程遍历页面上所有TextBox控件并给它赋值为string.Empty?

            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;
                    }
                }

     


  • 相关阅读:
    hust 1260 Dominos && hust 1516 Dominos
    poj 1149 PIGS
    hust 1230 beautiful
    poj 1469 COURSES
    hdu 3062 Party
    hust 1027 Enemy Target!
    hdu 3415 Max Sum of Max-K-sub-sequence
    简单的实现轮播代码
    window.parent与window.openner区别介绍
    plupload使用指南(转)
  • 原文地址:https://www.cnblogs.com/myx/p/1416370.html
Copyright © 2011-2022 走看看