Results 1 to 2 of 2

Thread: confirmation box

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width