I want to display a alert message when a user clicks on button.
I have a button "Signed
" on click of this button I want to display a alert message saying "Are you sure you want to continue?
" and two buttons in this alert message box "Yes
" and "No
".
On click of yes button I want a update function
to be executed and on click of "No
" only Alert should get closed and no changes in the current page.
Please anyone can guide me how to go on with this?
You can use the OnClientClick on the button for this. Add a return confirm(); to it. It will create a javascript confirm dialog, BEFORE it fires the click event. If the user presses no, it will not trigger the OnClick event.
OnClientClick="return confirm('Are you sure you want to continue?');"
So, added to your button markup, it would look like this:
<asp:Button ID="Button5" runat="server" Text="Signed" Visible="False" onclick="Button5_Click" OnClientClick="return confirm('Are you sure you want to continue?');" />
jquery should do for you.
$("#ButtonId").click({
return confirm("Are you sure you want to continue");
})
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