"i want used confirm in javascript in code behind"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thirunavukarasukm
    New Member
    • May 2007
    • 21

    "i want used confirm in javascript in code behind"

    Hai....

    "i want used confirm in javascript in code behind"

    i am used confirm button ,,,in code behind.

    if the confirm button worked

    the function is return the true...

    else

    the function return the false..

    i want to get true and false value for my further proces..

    this my code..

    Dim popupScript6 As String = "<script language='javas cript'>var agree= confirm('Are you sure to cancel the ticket?');if(ag ree){ return true};else {return false;}</script>"
    'Page.RegisterS tartupScript("P opupScript6", popupScript6)

    in my codebehind window i want to get "agree" value....

    in this popupScript6 used confirm coding is worked...but i wrote return word..this is nothing done..

    i ma used return word is not worked..

    please how can use this statement..

    how can i get return value..

    because i got the return value..

    then my next code if(true) the redirect to another page...

    so please hrlp me...

    i am used this code also code..

    but the same process done this also return word is used in not working..

    this code..

    Dim str As StringBuilder = New StringBuilder
    str.Append("<sc ript language='javas cript'>")

    str.Append("var agree= confirm('Are you sure to cancel the ticket?');")
    str.Append("if( agree){")

    str.Append("ret urn true;}")
    str.Append("els e {")

    str.Append("ret urn false;}")
    str.Append("</script>")
    RegisterStartup Script("TicketN umber", str.ToString)

    so please help me...
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Try using attributes.add( ). HTH.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You're on the right track.
      As Kenobewan said you'll need to uset the btn.Attributes. Add() function to add the onclick JavaScript to your button:

      [code=vbnet]
      BTN_Restart.Att ributes.Add("on click", "javascript : if(confirm('Are you sure you want to restart the process?')==tru e) {document.getEl ementById('__Re start').value=t rue;}")
      [/code]

      In this code a hidden field with the id="__Restart" is to true because the button will still submit the form to the server. When the Restart Button click event occurs check to see if this value is true or not and execute the appropriate code.

      Hope this helps!

      -Frinny

      Comment

      Working...