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. How to pass values from javascript to server-side

How to pass values from javascript to server-side

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmintutorial
7 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.
  • R Offline
    R Offline
    ratnakar_ravi
    wrote on last edited by
    #1

    How to pass values from javascript to server-side

    N 1 Reply Last reply
    0
    • R ratnakar_ravi

      How to pass values from javascript to server-side

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Using a hidden input field.

      Navaneeth How to use google | Ask smart questions

      R 1 Reply Last reply
      0
      • N N a v a n e e t h

        Using a hidden input field.

        Navaneeth How to use google | Ask smart questions

        R Offline
        R Offline
        ratnakar_ravi
        wrote on last edited by
        #3

        can u give an example

        C N 2 Replies Last reply
        0
        • R ratnakar_ravi

          can u give an example

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          1 - put a server hidden field in your page 2 - write the name of the field as a variable through to javascript, so you have the client side Id 3 - use document.getElementById to find the Id, and then set the value in JS 4 - on postback, read it from the hidden field.

          Christian Graus Driven to the arms of OSX by Vista.

          1 Reply Last reply
          0
          • R ratnakar_ravi

            can u give an example

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            <input type="hidden" name="txtHidden" id="txtHidden" runat="server">
            document.getElementById("txtHidden").value = "Set your value here"

            You can use txtHidden.Text on server side to get the value. :)

            Navaneeth How to use google | Ask smart questions

            C 1 Reply Last reply
            0
            • N N a v a n e e t h

              <input type="hidden" name="txtHidden" id="txtHidden" runat="server">
              document.getElementById("txtHidden").value = "Set your value here"

              You can use txtHidden.Text on server side to get the value. :)

              Navaneeth How to use google | Ask smart questions

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              runat=server won't change the id ? I see it's not a server control, but still, I did not know that.

              Christian Graus Driven to the arms of OSX by Vista.

              N 1 Reply Last reply
              0
              • C Christian Graus

                runat=server won't change the id ? I see it's not a server control, but still, I did not know that.

                Christian Graus Driven to the arms of OSX by Vista.

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Christian Graus wrote:

                runat=server won't change the id

                It will, only if the control is in a container(like panel etc). In such cases, it prefixes the container id with the control id to make the name unique. In normal cases, it won't.

                Navaneeth How to use google | Ask smart questions

                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