ASP.NET单选按钮列表的OnClientClick [英] ASP.NET radiobuttonlist onclientclick

查看:274
本文介绍了ASP.NET单选按钮列表的OnClientClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到没有的OnClientClick()属性在ASP.NET控件集在RadioButtonList。这是微软的一部分,有目的的omissiong?
无论如何,我已经尽力的OnClick添加到单选按钮列表,像这样:

I've noticed there is no OnClientClick() property for the radiobuttonlist in the ASP.NET control set. Is this a purposeful omissiong on Microsoft's part? Anyway, I've tried to add OnClick to the radio button list like so:

For Each li As ListItem In rblSearch.Items
    li.Attributes.Add("OnClick", "javascript:alert('jon');")
Next

但很可惜,这是行不通的。我甚至已经检查了源萤火虫,并没有在RadioButtonList的显示的JavaScript。有谁知道如何得到这个很简单的事情的工作?我使用ASP.NET控件adpaters所以不知道这是否有什么关系呢。

But alas, it doesn't work. I've even checked the source in firebug, and there is no javascript shown in the radiobuttonlist. Does anyone know how to get this very simple thing working? I'm using ASP.NET control adpaters so don't know if that has anything to do with it.

(我希望asp.net/javascript只想开箱!)

(I wish asp.net/javascript would just work out the box!!!)

推荐答案

我发现我可以只添加一个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.

这篇关于ASP.NET单选按钮列表的OnClientClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆