Jon Visconti
Jon Visconti

Reputation: 17

Confirmation Box on specific button click

I need a confirmation box to pop up when a user hits a Save button on my webpage. I currently have a confirm box showing up whenever a user hits ANY button. I need it strictly for the one. The button I need it linked to is called btnsavesurvey.

Here is my current code in the page_load:

Dim message As String = "Do you want to complete survey?"

    Dim sb As New System.Text.StringBuilder()

    sb.Append("return confirm('")

    sb.Append(message)

    sb.Append("');")

    ClientScript.RegisterOnSubmitStatement(Me.GetType(), "alert", sb.ToString())

Upvotes: 0

Views: 48

Answers (1)

Sven van den Boogaart
Sven van den Boogaart

Reputation: 12331

$('#btnsavesurvey').click(function(){
      var r = confirm("Your message");
      if (r == true) {
         alert("You pressed OK!");
          // Do something when the user pressed ok
      } else {
          alert("You pressed Cancel!");
          // Do something when the user pressed cancel
      };

 });

If your btns id is btnsavesurvey if its class is btnsavesurvey than use .btnsavesurvey

Upvotes: 1

Related Questions