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.
Add 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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.