-1

I have tried multiple things I have found on the web. What I am looking for is just to confirm the user is hitting cancel to NOT save changes. I need the code on the server side to get the result from the confirm.

I have a master page and 1 content page. I am new to using clientside so any help is greatly appreciated.

Here is what I tried but it only worked when I started the app. https://www.aspsnippets.com/Articles/ASPNet-Server-Side-Yes-No-Confirmation-Box-using-JavaScript.aspx

skifreak
  • 43
  • 9

1 Answers1

0

function cancelButtonClicked(event) {
  if (confirm("Confirm you don't want to save changes?")) {

    event.preventDefault();
    event.stopPropagation();
  }
}
<button type="button" onclick="cancelButtonClicked(event)">Cancel</button>
agrm
  • 3,735
  • 4
  • 26
  • 36
Dai
  • 141,631
  • 28
  • 261
  • 374
  • How do I get the response server-side? I also need to use server-side controls. This is a ASP.Net application. – skifreak Feb 01 '18 at 13:24
  • This is what I tried but it kept firing at page_load. I put the JS code on my master page and content page and still had the same issue.https://www.aspsnippets.com/Articles/ASPNet-Server-Side-Yes-No-Confirmation-Box-using-JavaScript.aspx. – skifreak Feb 01 '18 at 14:10