<asp:RadioButton id=RadioButton1 runat="server" GroupName="Sl"></asp:RadioButton>
.......
<asp:RadioButton id=RadioButton4 runat="server" GroupName="Sl"></asp:RadioButton>当RadioButton单选选中时触发事件怎么写
我这样写有误?
<asp:RadioButton id=RadioButton1 runat="server" GroupName="Sl" onclick="s1_click"></asp:RadioButton>
......
asp:RadioButton id=RadioButton4 runat="server" GroupName="Sl" onclick="s1_click"></asp:RadioButton>
.cs文件中
protected void s1_click(object sender, ImageClickEventArgs e)
    {
        ......
    }

解决方案 »

  1.   

    後臺是OnCheckedChanged事件吧,還要設置AutoPostBack屬性為true。當然用onclick觸發前臺方法也是可以的。
      

  2.   

    我这样写 不对
    <asp:RadioButton id=RadioButton1 runat="server"  GroupName="Sl" AutoPostBack="true"  onclick="s1_click()"></asp:RadioButton>onclick()没起作用
      

  3.   

    前台的控件应该是用 OnCheckedChanged 事件
    <asp:RadioButton ID="RadioButton1" runat="server" OnCheckedChanged="RadioButton1_CheckedChanged" />然后后台
     protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
            {
                 if(this.RadioButton1.Checked==true)
                 {
                    //你要做的事情
                   }
            }如果你要是想用onclick的话写js吧。
    比如:
    <asp:RadioButton ID="RadioButton2" runat="server" onclick="javascript:alert('aaaaaaaa');"  />
      

  4.   

    双击进去就行了,出来事件
    加上 autopostback这个属性 
      

  5.   

    TO 6楼用你的OnCheckedChanged 事件实现我要做的事,但是反应很慢(要双击才行),能不能实现我点击单选按钮就实现我要做的事
    前台的控件应该是用 OnCheckedChanged 事件
    <asp:RadioButton ID="RadioButton1" runat="server" OnCheckedChanged="RadioButton1_CheckedChanged" />然后后台
     protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
      {
      if(this.RadioButton1.Checked==true)
      {
      //你要做的事情
      }
      }
      

  6.   

    选中radiobutton的属性,把AutoPostBack设置为 true
      

  7.   

    to 10楼 我加了的 
     OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">但RadioButton1_CheckedChanged反应太慢
    我想实现选中就相应事件
      

  8.   

    10楼说的对,刚才忘了把AutoPostBack设置为 true了。
    就是你选中那个RadioButton1,然后在属性窗口里
      

  9.   

    我选中之后处理
     protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            string id;
            id = Request.QueryString["tt"].ToString();
            if (this.RadioButton1.Checked == true)
            {
     this.RadioButton1.InputAttributes.Add("onclick", "parent.left.document.getElementById('" + id + "').innerText='A'");
                       }
        }
    多嘛?
      

  10.   

    我选中等了半天 没执行
    我双击很快就执行to 10楼 我加了的  
     OnCheckedChanged="RadioButton1_CheckedChanged" AutoPostBack="true">但RadioButton1_CheckedChanged反应太慢
    我想实现选中就相应事件