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. ViewState in Html Controls

ViewState in Html Controls

Scheduled Pinned Locked Moved ASP.NET
htmlquestion
2 Posts 2 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.
  • U Offline
    U Offline
    User 768313
    wrote on last edited by
    #1

    hi all,how can i keep the value of an html control when i make a postback for the page. thanks

    C 1 Reply Last reply
    0
    • U User 768313

      hi all,how can i keep the value of an html control when i make a postback for the page. thanks

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      If the control is a server side control then it should all be handled by ASP.NET. If not check to ensure that you've set EnableViewState to true in the code-behind and/or the designer. If it is a regular html control then you can't, unless it is part of a literal control. Then on your postback you'll get all the html in the literal control through the viewstate. If you don't want to change a regular HTML control in to an ASP.NET control you can set up some javaScript to populate a hidden field on the html page with the value from the control you want in the postback. When the page is posted back the value will be availble in the forms collection. e.g. Request.Form["myHiddenHtmlInputControlId"] Good Luck. --Colin Mackay--

      "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#

      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