Question

I had a simple page like this:

A.aspx - has an asp TabControl make user change to B.aspx or back, and a button will use javascript confirm user to do something.

B.aspx - has the same TabControl like A.aspx , just show some message here.

button code in A.aspx like this:

<button id="do" onclick="if (confirm('you sure?')==false) { return false; };"></button>

and my Response.Redirect code in A.aspx.cs TabControl_TabChanged() like this:

Response.Redirect("b.aspx");

It work fine before I click the button, if I click it and select 'ok' it still fine, but when I select 'cancel', the Response.Redirect() will run but the page didn't change. please help me find the problem.

Was it helpful?

Solution 2

I would try to set a jQuery event on my Button

<form id="submitform">
 <button id="do" >change</button>
</form>

 $("#do").click(function(e) {
  var r=confirm("you sure?");
       if (r===false)
       {
          e.preventDefault();
       }
 });

perhaps this helps

OTHER TIPS

Just Replace 'onclick' for javascript with 'OnClientClick'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top