Attributes.Add Onclick (javascript) trapping CANCEL

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?
 
S

Stormbringer

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
 
R

rodchar

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?')")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top