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. Redrawing dynamically added controls

Redrawing dynamically added controls

Scheduled Pinned Locked Moved Web Development
helpcsharpasp-nettutorialquestion
6 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.
  • W Offline
    W Offline
    whaletail100
    wrote on last edited by
    #1

    I have created an aspx form where most of the controls are added dynamically. If I redraw the form with the same set of control, the dynamic controls do not seem to be redrawn with the new values. For example, I have checkbox that was checked. I select my button to reset it. Stepping through the code, I see the checkbox checked property is set to false. The form comes back up as if nothing has been altered. The checkbox is still checked. Has anyone else run into this problem with ASP.NET? If so, how did you resolve this issue?

    N 1 Reply Last reply
    0
    • W whaletail100

      I have created an aspx form where most of the controls are added dynamically. If I redraw the form with the same set of control, the dynamic controls do not seem to be redrawn with the new values. For example, I have checkbox that was checked. I select my button to reset it. Stepping through the code, I see the checkbox checked property is set to false. The form comes back up as if nothing has been altered. The checkbox is still checked. Has anyone else run into this problem with ASP.NET? If so, how did you resolve this issue?

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Are all of your controls tagged with runat="server" within the tag? Your subroutine written in VB running on the server to reset the values will only work on controls that have that prefix. Also make sure you wrap your controls within a form tag.

      .... ... HTH Nick Parker

      W 1 Reply Last reply
      0
      • N Nick Parker

        Are all of your controls tagged with runat="server" within the tag? Your subroutine written in VB running on the server to reset the values will only work on controls that have that prefix. Also make sure you wrap your controls within a form tag.

        .... ... HTH Nick Parker

        W Offline
        W Offline
        whaletail100
        wrote on last edited by
        #3

        Here is a snippet of my VB code that adds a dropdown listbox to my form dynamically. How do I set the controls in my VB code to force it to runat server? Dim tmpDDLB As System.Web.UI.WebControls.DropDownList Dim lstitem As ListItem lstitem = New ListItem("A", "0") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "1") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "2") tmpDDLB.Items.Add(lstitem) tmpDDLB.SelectedIndex = 0 MyForm.Controls.Add(tmpDDLB)

        N C 2 Replies Last reply
        0
        • W whaletail100

          Here is a snippet of my VB code that adds a dropdown listbox to my form dynamically. How do I set the controls in my VB code to force it to runat server? Dim tmpDDLB As System.Web.UI.WebControls.DropDownList Dim lstitem As ListItem lstitem = New ListItem("A", "0") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "1") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "2") tmpDDLB.Items.Add(lstitem) tmpDDLB.SelectedIndex = 0 MyForm.Controls.Add(tmpDDLB)

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Your controls are runat=server, they are certainly not being created on the client. Make sure you are persisting the value you want to change. Remember when the page reloads it is redrawing the controls as if for the first time.

          1 Reply Last reply
          0
          • W whaletail100

            Here is a snippet of my VB code that adds a dropdown listbox to my form dynamically. How do I set the controls in my VB code to force it to runat server? Dim tmpDDLB As System.Web.UI.WebControls.DropDownList Dim lstitem As ListItem lstitem = New ListItem("A", "0") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "1") tmpDDLB.Items.Add(lstitem) lstitem = New ListItem("C", "2") tmpDDLB.Items.Add(lstitem) tmpDDLB.SelectedIndex = 0 MyForm.Controls.Add(tmpDDLB)

            C Offline
            C Offline
            Chris Rickard
            wrote on last edited by
            #5

            If this code is in your Init event make sure your checking for Page.IsPostBack otherwise your controls get re-created and initialized on every PostBack.

            W 1 Reply Last reply
            0
            • C Chris Rickard

              If this code is in your Init event make sure your checking for Page.IsPostBack otherwise your controls get re-created and initialized on every PostBack.

              W Offline
              W Offline
              whaletail100
              wrote on last edited by
              #6

              I do check to postback and the controls are redrawn with the new values. However, the UI displays them as if no change has occurred. I can even step through my code, see the values being reset, and the UI will not reflect the change. Any other suggestions?

              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