日期:2014-05-19  浏览次数:20815 次

编译出错?????
private   void   btn_Return_Click(object   sender,   System.EventArgs   e)
{
  foreach   (Control   c   in   this.Form.Controls)
      {
      if   (c.GetType()   ==   typeof(TextBox))   (c   as   TextBox).Text   =   " ";
      }
}
         
编译是出现:不可访问“System.Web.UI.Page.Form”,因为它受保护级别限制

------解决方案--------------------
foreach(Control ct in Page.Controls)
{
foreach(Control ct1 in ct.Controls)
{
if(ct1.GetType().ToString()== "System.Web.UI.WebControls.CheckBox ".ToString())
{
((CheckBox)ct1).Checked=false;
}
}
}