Re: JavaScript confirm



Are you asking on the server side? Your code already does it. If Cancel is
clicked, the event won't propagate to the server.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


<rn5a@xxxxxxxxxxxxxx> wrote in message
news:1161853312.870679.122810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have gone through a no. of posts in this NewsGroup regarding my
problem but alas, couldn't come across one which would have helped me
in resolving the issue. My problem is this:

An ASPX Form has a Button. When the Button is clicked, I want a
JavaScript confirm dialog to pop-up with the options 'OK' & 'Cancel'. I
have done this using the following code:

Sub Page_Load(....)
btnClick.Attributes.Add("OnClick", "javascript:return confirm('Are
you sure you want to exit?');")
End Sub

where 'btnClick' is the name of the Button.

The problem is how do I find out which of the 2 buttons, 'OK' or
'Cancel', has a user clicked? Any one can help me out with this?

My primary intention is if the user clicks 'OK' in the confirm dialog,
then function1 should get executed but if the user clicks 'Cancel',
then function2 should get executed.

In JavaScript, if 'OK' is clicked, then confiorm returns 1; if 'Cancel'
is clicked, then confirm returns 0.



.


Loading