能从Asp:RadioButtonList调用客户端和服务器端代码吗?
问题描述:
我目前调用从同一按钮点击这样的客户端功能和服务器端功能...能从Asp:RadioButtonList调用客户端和服务器端代码吗?
<asp:Button id="myButton"
runat="server"
cssclass="myButtonClass"
text="Do Stuff"
onclick="Do_Foo"
OnClientClick="Do_Bar();"/>
我想知道如果事情analagous是可能的一个单选按钮列表...
<asp:RadioButtonList id="myRadioButtonList"
runat="server"
AutoPostBack="True"
onselectedindexchanged="Do_Fum"
...er...something here?>
<asp:ListItem ...or here perhaps?... Value="0">First Button</asp:ListItem>
.
.
答
您可以使用下面的方法:在p的下方粘贴代码年龄的Page_PreRender
事件处理程序
foreach (ListItem item in myRadioButtonList.Items)
{
item.Attributes["onclick"] = "if(!confirm('Are you sure?'))return false";
}
答
您可以在javascript挂钩的改变事件单选按钮像
$('#myRadioButtonList').change(function() {
alert('Handle Your Change');
});
+0
谢谢。我应该把那个小片段放在哪里? –
+0
其jquery,只是把它放在'
+0
右键。谢谢,我明天再试。 –
谢谢。那是第一次。 –