Radiobutton onCheckedChagned事件

时间:2013-08-06 11:44:40

标签: asp.net .net vb.net

尝试实现radiobutton onCheckedChanged事件但是函数后面的代码没有触发可以有人指出我到底是怎么回事以下代码。

Aspx页面

<asp:RadioButton runat="server" checked="true" OnCheckedChanged="Check_Clicked"    AutoPostBack="true"   groupname="parent_category" id="rbCat1"  />
 <asp:RadioButton runat="server" checked="false" OnCheckedChanged="Check_Clicked"  AutoPostBack="true"   groupname="parent_category" id="rbCatCream"  />

背后的代码

  Public Sub Check_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs)
    dim test as string =""
  end sub

提前谢谢。

2 个答案:

答案 0 :(得分:0)

试试这个

 <asp:RadioButton runat="server" checked="true" OnCheckedChanged="Check_Clicked"    AutoPostBack="true"   groupname="parent_category" id="rbCat1"  />
 <asp:RadioButton runat="server"  OnCheckedChanged="Check_Clicked"  AutoPostBack="true"   groupname="parent_category" id="rbCatCream"  />


Protected Sub Check_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles rbCat1.CheckedChanged, rbCatCream.CheckedChanged
   dim test as string =""
end sub

答案 1 :(得分:0)

试试这个。

  <asp:RadioButtonList ID="rdolist" AutoPostBack="true" runat="server" OnSelectedIndexChanged="rdolist_SelectedIndexChanged">
    <asp:ListItem Text="test" Value="test"></asp:ListItem>
    <asp:ListItem Text="test1" Value="test1"></asp:ListItem>
  </asp:RadioButtonList>

// on code behind
Protected Sub rdolist_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdolist.SelectedIndexChanged
   // your code
end sub