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. getting html hidden control's value in code behind

getting html hidden control's value in code behind

Scheduled Pinned Locked Moved ASP.NET
htmlsysadmin
8 Posts 4 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.
  • M Offline
    M Offline
    max_dev2006 yahoo com
    wrote on last edited by
    #1

    hi i need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting. Request.form["refid"] is not working. so can u sugges some idea regards max

    D E G 3 Replies Last reply
    0
    • M max_dev2006 yahoo com

      hi i need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting. Request.form["refid"] is not working. so can u sugges some idea regards max

      D Offline
      D Offline
      dgonzale
      wrote on last edited by
      #2

      add runat="server" (from the html view) as a property of your hidden field, it will continue to work as a hidden field and it will allow you to read its value in the code behind. :~ It might have a different way to solve this issue but this worked for me. Let me know if it works for you.

      1 Reply Last reply
      0
      • M max_dev2006 yahoo com

        hi i need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting. Request.form["refid"] is not working. so can u sugges some idea regards max

        E Offline
        E Offline
        Exelioindia
        wrote on last edited by
        #3

        Dont mistake me, i have an small doubt, did you declared the tag inbetween the

        tags???? Because all other things are correct.

        Know is Drop, Unknown is Ocean

        D 1 Reply Last reply
        0
        • M max_dev2006 yahoo com

          hi i need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting. Request.form["refid"] is not working. so can u sugges some idea regards max

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          If you have put the hidden field inside the form that you are posting, you can get the value using Request.Form.

          --- b { font-weight: normal; }

          D 1 Reply Last reply
          0
          • E Exelioindia

            Dont mistake me, i have an small doubt, did you declared the tag inbetween the

            tags???? Because all other things are correct.

            Know is Drop, Unknown is Ocean

            D Offline
            D Offline
            dgonzale
            wrote on last edited by
            #5

            Exelioindia, Yes; :confused: like I said on my reply, it might be a different approach to solve this issue but this worked for me.

            1 Reply Last reply
            0
            • G Guffa

              If you have put the hidden field inside the form that you are posting, you can get the value using Request.Form.

              --- b { font-weight: normal; }

              D Offline
              D Offline
              dgonzale
              wrote on last edited by
              #6

              it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value. David

              G 1 Reply Last reply
              0
              • D dgonzale

                it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value. David

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                dgonzale wrote:

                it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value.

                Only if you add the runat and id properties to the element. Otherwise the element is treated as plain text by the server. There is no need to make a server element of it to access the value that it sends in the post.

                --- b { font-weight: normal; }

                D 1 Reply Last reply
                0
                • G Guffa

                  dgonzale wrote:

                  it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value.

                  Only if you add the runat and id properties to the element. Otherwise the element is treated as plain text by the server. There is no need to make a server element of it to access the value that it sends in the post.

                  --- b { font-weight: normal; }

                  D Offline
                  D Offline
                  dgonzale
                  wrote on last edited by
                  #8

                  Ooops! Yes you're right, i forgot about the id property, thanks Guffa. David

                  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