textbox ,dropdownlist,checkbox都有,請問有什麼好方法嗎?

解决方案 »

  1.   

    DropDownList和CheckBox哪来ReadOnly属性?
      

  2.   

    楼主是要禁用吗?可以这样试试:foreach(Control ctrl in this.Controls[1].Controls){
    if(ctrl is TextBox)
    ctrl.ReadOnly=true;
    else if(ctrl is ListControl||ctrl is CheckBox)
    ctrl.Enabled=false;
    }
      

  3.   

    E:\test\web\s1sf\s1sf_yarn_edit.aspx.cs(295): 'System.Web.UI.Control' does not contain a definition for 'Enabled'這樣的報錯.請問怎麼回事呢?
      

  4.   

    E:\test\web\s1sf\s1sf_yarn_edit.aspx.cs(295): 'System.Web.UI.Control' does not contain a definition for 'ReadOnly'這樣的報錯.請問怎麼回事呢?
      

  5.   

    对不起,因为没有将ctrl转换为相应的控件,转换一下:foreach(Control ctrl in this.Controls[1].Controls){
    if(ctrl is TextBox)
    ctrl.ReadOnly=true;
    else if(ctrl is ListControl||ctrl is CheckBox)
    ((WebControl)ctrl).Enabled=false;
    }
      

  6.   

    晕,第一个忘转换了,再改一下:foreach(Control ctrl in this.Controls[1].Controls){
    if(ctrl is TextBox)
    ((TextBox)ctrl).ReadOnly=true;
    else if(ctrl is ListControl||ctrl is CheckBox)
    ((WebControl)ctrl).Enabled=false;
    }
      

  7.   

    比较简单的方法:
    遍历页面上的所有控件,
    按钮类型的控件就 disable。这样可以达到的效果是:
    用户虽然可以只有修改页面的内容,
    但肯定不能提交。