Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using Javascript confirm box in Asp.net

Using Javascript confirm box in Asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthtmlasp-netquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandeep kumar pundhir
    wrote on last edited by
    #1

    hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep

    A J 2 Replies Last reply
    0
    • S sandeep kumar pundhir

      hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep

      A Offline
      A Offline
      ali bagheri
      wrote on last edited by
      #2

      you can write code below in code behind Page_Load() { if(!ispostback) { button.attribute.Add("onclick","return confirm('Are you sure to perform this action?');") } } if this button click first confirm execute and if select OK the code behind of button execute. bye

      1 Reply Last reply
      0
      • S sandeep kumar pundhir

        hi, i m writing thr following code to pop up the confirmation box in Asp.net. i do not want to write a function in html file and call it in code behind using button.attribute.Add . I want to write all the code in code behind file.If the user chooses YES then something is done else the code after that is not executed if(Button11.text=="sandeep") { string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this action?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", strScript); TextBox1.text="you are Rejected"; } This is not working . waiting reply sandeep

        J Offline
        J Offline
        Jax_qqq
        wrote on last edited by
        #3

        see this what i have done... Button1.Attributes.Add("onclick","javascript:return confirmReject();"); string strScript= ""; strScript = ""; strScript = strScript + "function confirmReject(){"; strScript = strScript + "if (confirm('Are you sure to perform this?')==true)"; strScript = strScript + "{return true;}"; strScript = strScript + "else"; strScript = strScript + "{return false;}}"; strScript = strScript + ""; Response.Write(strScript); i have this code in pageload only...and it's working fine... i hope this will help u out Thanx Anuj Kamthan Software Developer Solversa Technologies, Pune - 411007, India. http://www.solversa.com -- modified at 6:22 Monday 22nd May, 2006

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups