b/s结构 DropDownList1,TextBox1 控件 
当DropDownList1 选择值为a时,TextBox1不能编辑 
当DropDownList1 选择值为b时,TextBox1i可编辑

解决方案 »

  1.   

    将DropDownList的AutoPostBack设为true,然后在它的SeletedChanged事件中写
    if(DropDownList1.SelectedValue == "a")
        TextBox1.Enabled = true;
    else if(DropDownList1.SelectedValue == "b")
        TextBox1.Enabled = false;
      

  2.   

    如果要求不刷新2个办法
    1JS
    2AJAX可以刷新就简单了
    把DropDownList的autoPostback开开然后就和C/S一样拉if(DropDownList1.SelectedItems.Text=="a")
    {
      TextBox1.Enable=false;
    }
    else
    {
      TextBox1.Enable=true;
    }
      

  3.   

    function SetEnable()
    {
       var list=document.getElementByID(“DropDownList1”);
       if(list.value=="a")
       {
          document.getElementByID("TextBox1").readOnly=true;
       }
       else
       {
           document.getElementByID("TextBox1").readOnly=false;
       }
    }
      

  4.   


    写在DropDownList的SelectedIndexChanged事件里面,DropDownList的属性AutoPostBack="True"
     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue.ToString() == "a")
            {
              TextBox1.Enabled = false;
            }
            if (DropDownList1.SelectedValue.ToString() == "b")
            {
              TextBox1.Enabled = true;
            }
        }