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. Dynamically adding controls to a page

Dynamically adding controls to a page

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

    Hello all, I have a page that has a number of items on it (ImageButtons, to be exact). When an image button is clicked, it posts back and I use the ModalPopupExtender to bring up a modal dialog that can contain a user control that is loaded dynamically, depending on what was clicked. After a button on the modal popup is clicked, I need to save changes into a hidden field on the form. However, after postback, the control is totally gone. How do I need to recover the data that was in the form?

    C 1 Reply Last reply
    0
    • G gantww

      Hello all, I have a page that has a number of items on it (ImageButtons, to be exact). When an image button is clicked, it posts back and I use the ModalPopupExtender to bring up a modal dialog that can contain a user control that is loaded dynamically, depending on what was clicked. After a button on the modal popup is clicked, I need to save changes into a hidden field on the form. However, after postback, the control is totally gone. How do I need to recover the data that was in the form?

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

      Your control needs to be created every time, and it won't have viewstate unless it's created before page load. I'd use a hidden control to track data from the control, and what controls exist.

      Christian Graus Driven to the arms of OSX by Vista.

      M 1 Reply Last reply
      0
      • C Christian Graus

        Your control needs to be created every time, and it won't have viewstate unless it's created before page load. I'd use a hidden control to track data from the control, and what controls exist.

        Christian Graus Driven to the arms of OSX by Vista.

        M Offline
        M Offline
        Mike Holpuch
        wrote on last edited by
        #3

        Another option would be to use the viewstate to track data from the control. You just have to manually set the data in the viewstate. I prefer this method because you can store any serializable object in the viewstate, so it gives you more control over how the data is stored. Plus, you can use viewstate encryption to encrypt the data and prevent users from seeing the contents.

        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