Attributes.Add Onclick (javascript) trapping CANCEL

  • Thread starter Thread starter jobs
  • Start date Start date
J

jobs

re: Attributes.Add Onclick (javascript) trapping CANCEL

Hello. The following asp.net/vb.net code produces a confirmation

Submitbutton.Attributes.Add("onClick", "return confirm('Is this
okay?')")

My question is, when the confirmation comes up, I want cancel to do a
back. Currently it just stops the form from posting.

any suggestions?
 
Don't return the value from confirm. If you need to know that it was canceled
you would need to store that value somewhere in the page and then let it post.

if (confirm('Is this okay?'))
{
//ok logic
}
else
{
//cancel logic
}
return true; //form will post back
 
i would do something like the following:

<script type="text/javascript">
function myfx( )
{
function disp_confirm()
{
var r=confirm("Press a button")
if (r==true)
{
document.write("You pressed OK!")
}
else
{
document.write("You pressed Cancel!")
return true
}
}
}
</script>


Submitbutton.Attributes.Add("onClick", "return myfx('Is this
okay?')")
 
Back
Top