Display warning window in ASP.net C # web application

I want to display a warning message when the user clicks a button.

I have a " Signed " button when I click this button. I want to display the warning message “ Are you sure you want to continue? ” And the two buttons in this warning window “ Yes ” and “ No ”.

When I click "Yes", I want to execute the update function and click " No ". The warning should be closed and no changes to the current page.

Please can someone advise me how to do this?

+4
source share
2 answers

You can use OnClientClick on the button for this. Add confirmation of return (); to him. It will create a javascript confirmation dialog before it fires the click event. If the user clicks no, he will not raise the OnClick event.

 OnClientClick="return confirm('Are you sure you want to continue?');" 

So, added to the layout of your button, it will 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?');" /> 
+9
source

jquery should do for you.

 $("#ButtonId").click({ return confirm("Are you sure you want to continue"); }) 
+1
source

Source: https://habr.com/ru/post/1385850/


All Articles