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
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.
(I wish asp.net/javascript would just work out the box!!!)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With