-
confirmation box
Hi,
I have the following code to show a confirmation box, it works fine without the return false/true part.
I tried to add the return true or false part to get the result of the confirmation box, but nothing is happening.
How can I catch if the user clicked yes or no in my asp.net code?
Code:
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">var r=confirm(""Press a button"");" _
+ "if (r==true) { alert(""You pressed OK!""); return true; } else { return false ; alert(""You pressed Cancel!""); return false; }</SCRIPT>")
thanks
-
Re: confirmation box
Hello,
My first advice would be to not use Response.Write. If you need to inject JavaScript into the page then do so using the RegsiterClientScript or RegisterStartupScript methods.
From the above code, are you getting any JavaScript errors on the page? If so, what are they?
Gary