且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET单选按钮列表的OnClientClick

更新时间:2022-11-09 11:43:10

我发现我可以只添加一个onclick属性的单选按钮列表,并预期这将触发的JavaScript客户端。

I found I could just add a onclick attribute to the RadioButtonList and it would fire the javascript client side as expected.

<asp:RadioButtonList ID="RadioButtonList1" runat="server" onclick="alert('RadioButtonListSelectChange');">
    <asp:ListItem Text="One" Value="1"/>
    <asp:ListItem Text="Two" Value="2"/>
</asp:RadioButtonList>

您可以再编写一个客户端脚本,可以判断当前选中的列表项。

You could then write a client script that could determine the currently selected list item.