protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (Control co in Page.Controls)
        {
            if (co is TextBox)
            {
                
                TextBox b = (System.Web.UI.WebControls.TextBox)co;
                b.Text = string.Empty;
           
            }
        }
    }
我想对页面所有TextBox控件进行操作;可惜实现不了string.Empty;是我哪写错的么

解决方案 »

  1.   

    Page.Controls    -》  form1。Controls    
      

  2.   

     b.Text = "";
    就可以了,
    浏览器没有null值这个东西
      

  3.   

    textBox在页面源码里都是input,用js的方法就行了
    function Setvalue()
    {
       var a=document.getElementsByTagName("input");
       for(var i=0;i<a.length;i++)
       {
         if(a[i].type="Text")
         {
          a[i].value="";
         }
    }
    }
      

  4.   

    if(a[i].type="Text")
    这个是if(a[i].type=="Text")
      

  5.   

       protected void Button1_Click(object sender, EventArgs e)
            {
                TextBox txt = null;
                foreach (Control co in Page.Controls)
                {
                    if (co.GetType().Name == "HtmlForm")
                    {
                        foreach (Control c1 in co.Controls)
                        {
                            if (c1.GetType().Name == "TextBox")
                            {
                                txt = ((TextBox)c1);
                                txt.Text = "bbb";
                            }
                        }
                    }
                }
            }