解决方案 »

  1.   

    foreach遍历控件集合,里面if判断即可
      

  2.   

    foreach(Control c in this.Controls)
    {
        if(c is TextBox)
        {
            if(string.IsNullorEmpty((c as TextBox).Text))
            {
                //是否为空
            }
        }
    }
      

  3.   

    控件不能为空设置示例
    <asp:TextBox ID="txtName" runat="server" Width="235px" Font-Size="9pt"></asp:TextBox>//用户名设置
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" Font-Size="9pt" ErrorMessage="用户名不允许为空">*</asp:RequiredFieldValidator>//不能为空设置
    <asp:Button ID="btnCheck" CssClass="ButtonCss" runat="server" CausesValidation="False" Text="检测用户" Font-Size="9pt"  OnClick="btnCheck_Click" Width="120px" />//检测设置
    //检测事件是否可以操作
     protected void btnCheck_Click(object sender, EventArgs e)
        {
            SqlData da = new SqlData();
            SqlDataReader read = da.ExceRead("select * from tb_Blog where UserName='" + this.txtName.Text + "'");
            read.Read();
            if (read.HasRows)
            {
                if (this.txtName.Text == read["UserName"].ToString())
                {                Response.Write("<script language=javascript>alert('对不起,该用户已经存在!');location='Register.aspx'</script>");
                }
            }//CodeGo.net/
            else
            {
                Response.Write("<script language=javascript>alert('恭喜您,该用户可以登陆!');location='javascript:history.go(-1)'</script>");
            }
            read.Close();
        }
      

  4.   

    foreach遍历控件集合,里面if判断即可 这个可以  如果是指定的几个控件  那个多写几条if
      

  5.   

    bool is有空数据;//
    foreach(Control c in this.Controls)
    {
        if(c is TextBox)
        {
            if(string.IsNullorEmpty((c as TextBox).Text))
            {
                is有空数据 = true;
                return;
            }
        }

    is有空数据 = false;// 所有文本控件不为空
      

  6.   

    bool is有空数据;//
    foreach(Control c in this.Controls)
    {
        if(c is TextBox)
        {
            if(string.IsNullorEmpty((c as TextBox).Text))
            {
                is有空数据 = true;
                return;
            }
        }

    is有空数据 = false;// 所有文本控件不为空
      

  7.   

    你是要判断,还是要控制?
    判断
       方法1:循环容器中(你的文本控件是放在哪个容器中的,比如panl,form)的控件,如果是文本,则判断是否为空,如果所有的文本不是放在同一个容器中的,那么写个递归方法
       方法2:将所有文本控件的值改变事件指向同一个方法,根据当前焦点来获得是哪个文本控件控制:同上,原理一样,用正则控制不能为空,