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. Get variable from javascript

Get variable from javascript

Scheduled Pinned Locked Moved ASP.NET
questioncsharpjavascriptdatabasehelp
5 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.
  • C Offline
    C Offline
    Commickey
    wrote on last edited by
    #1

    I have this javascript: function ConfirmationWindow() { var result = confirm("Are you sure"); } This pops up a window for confirmation. Based on a yes or no selection by the user, I will like to insert or delect some data from a database but my problem is that, how do I get the true/false value of "result" which is in javascript and use it in my C#? Any suggestion will be great Thanks alot, Commickey

    V 1 Reply Last reply
    0
    • C Commickey

      I have this javascript: function ConfirmationWindow() { var result = confirm("Are you sure"); } This pops up a window for confirmation. Based on a yes or no selection by the user, I will like to insert or delect some data from a database but my problem is that, how do I get the true/false value of "result" which is in javascript and use it in my C#? Any suggestion will be great Thanks alot, Commickey

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      U can take one Hidden textbox of html and store true or false depending on the selection of Yes or No by the User. Brfore saving the record u first check the value of the hidden textbox and the save it. I hope u got what I want to say. Thanks and Regards.

      C R 2 Replies Last reply
      0
      • V varshavmane

        U can take one Hidden textbox of html and store true or false depending on the selection of Yes or No by the User. Brfore saving the record u first check the value of the hidden textbox and the save it. I hope u got what I want to say. Thanks and Regards.

        C Offline
        C Offline
        Commickey
        wrote on last edited by
        #3

        sorry, can u help me with a code on how to do this?

        V 1 Reply Last reply
        0
        • C Commickey

          sorry, can u help me with a code on how to do this?

          V Offline
          V Offline
          varshavmane
          wrote on last edited by
          #4

          Hi, Just Drag and drop html hidden textbox on ur wen form and write the following javascript code and the changes accordingly... function CommitChanges() { document.all("<%=htxtSName.ClientID%>").value = document.all("txtShortName").value; document.all("<%=htxtLogName.ClientID%>").value = document.all("txtLogin").value; var text = "Do you want to save the changes?"; if(!confirm(text)) { document.all("<%=htxtSave.ClientID%>").value = false; return true; } else { document.all("<%=htxtSave.ClientID%>").value = true; return true; } Use this code for ur reference.htxtSave is the hidden textbox. Thanks and Regards.

          1 Reply Last reply
          0
          • V varshavmane

            U can take one Hidden textbox of html and store true or false depending on the selection of Yes or No by the User. Brfore saving the record u first check the value of the hidden textbox and the save it. I hope u got what I want to say. Thanks and Regards.

            R Offline
            R Offline
            RichardGrimmer
            wrote on last edited by
            #5

            Another approach would be to have a button on the form that isn't displayed, which calls the update routine on the server - the check would then be something like.... res = confirm('do something?'); if (res) { document.getElementById('MyASPNETButton').click(); } "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

            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