I have a Radio button in a Gridview and when we click on the button, i'm calling function in the code behind file(user control). Before that i need to implement need call a javascript function to confirm about change. I tried onclick, OnClientClick, OnSelect and none of them worked as expected.
<asp:RadioButton ID="ratiobuttonChoose" runat="server" AutoPostBack="true"
OnCheckedChanged="Selected"/>
Can someone, please suggest me how to do this one.
I have a Radio button in a Gridview and when we click on the button, i'm calling function in the code behind file(user control). Before that i need to implement need call a javascript function to confirm about change. I tried onclick, OnClientClick, OnSelect and none of them worked as expected.
<asp:RadioButton ID="ratiobuttonChoose" runat="server" AutoPostBack="true"
OnCheckedChanged="Selected"/>
Can someone, please suggest me how to do this one.
Share edited Sep 15, 2015 at 2:30 zed 2,3384 gold badges28 silver badges45 bronze badges asked Sep 14, 2015 at 23:18 user4872443user4872443 2- 2 I've read in SO that onclick works – Jaromanda X Commented Sep 14, 2015 at 23:25
- 1 It's not case sensitive is it? onClick? – Mathemats Commented Sep 14, 2015 at 23:27
1 Answer
Reset to default 6Add a script on Page_Load in code behind:
ratiobuttonChoose.Attributes.Add("onclick", "clientJsFunction()");
Reference: MSDN
You can add onclick direct on your tag (VisualStudio don't suggest but it works):
<asp:RadioButton ID="ratiobuttonChoose" runat="server" AutoPostBack="true"
OnCheckedChanged="Selected" onclick="alert('Clicked!');" />
You can also use jQuery, see here.