我想根据radioButton1的Checked为true时,TextBox的disabled属性也为真。
用radioButton1的事件很容易实现,但是会刷新,很不爽。
听说JAVASCRIPT可以实现,是不是用radioButton1.Attribute.add("","javascript:")来做啊,具体怎么实现啊?

解决方案 »

  1.   

    <input type = "radio">
      

  2.   

    前面的大部分工作都是用C#完成的,用的控件也是服务器控件radioButton。
    现在换成input不太现实,只是剩下一个小问题,就是让radioButton选中的时候TextBox1无效。
    用javascript应该很容易实现吧
      

  3.   

    手工在HTML里加上onclick="javascript:checkit()",如果radioButton是动态产生的的话就不能这样了.
    我一般用另一个办法:用C#动态产生<input type=radio name=chk value='' onclick='javascript:getData();'>
    然后在客户端getData()去定义你要的任何一个控件的属性
      

  4.   

    <asp:RadioButton id="RadioButton1" onclick="RadioButton1Check();" style="Z-INDEX: 103; LEFT: 304px; POSITION: absolute; TOP: 640px"
    runat="server"></asp:RadioButton>
    function RadioButton1Check()
    {
       if(document.all.RadioButton1.value = true)
      { 
        document.all.txt.disabled=false
      }
    }
      

  5.   

    RadioButton1.Attributes.Add("onclick", "TextBox1.disabled=RadioButton1.checked;")
      

  6.   

    <script language="javascript">
    <!--
    function test1()
    {
    if (document.all["test"].checked == true)
    {
    document.all["txt_test"].disabled = false;
    }}
    //-->
    </script><input id="test" type="radio" name="1" onclick="test1();">
    <input id="txt_test" disabled>
    -------------------------------------------------------
    把上面的改为WEB控件
    把onclick 不要..
    在后台加
    test.Attribute.add("onclick","test1();");
      

  7.   

    给radioButton加一个客户端的事件就好了
    在这个方法里返回false就不会执行服务器端事件radioButton.Attribute.add("onclick","return test1();");function test1()
    {
        //process
        return false;
    }