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. Strange Behaviour with dynamic controls and postback processing

Strange Behaviour with dynamic controls and postback processing

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharpasp-netcom
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.
  • M Offline
    M Offline
    Matt Daley
    wrote on last edited by
    #1

    Hello, I came across something strange and I wonder whether anyone might know why it occurs? I have a page populated with dynamic controls. Ever time a postback occurs the controls are recreated with the same ids, before postback processing occurs, so that the controls are redisplayed with their values from the previous postback. (An aside: I'd be very interested to know how ASP.NET does this postback processing?). Before anyone comments, I am doing this because the page is too complicated to do any other way (I tried it using a repeater but got stuck once I started to building dynamic controls, including controls that generate events, within dynamic controls within a repeater!). It turned out to be easier to do this as a flat page of many dynamic controls and it does work. However, here was the strange behaviour. If I named a dynamic control, say a textbox with an id that contained a colon (:) any value I put in it is not kept across postbacks. If I replace the colon with an underscore (_) then the value is kept. So, why does the : cause a problem? Does it have some sort of special meaning for post-back processing? Regards, Matt Matt Daley Imutome Limited Bristol, United Kingdom matt.daley@imutome.com

    U 1 Reply Last reply
    0
    • M Matt Daley

      Hello, I came across something strange and I wonder whether anyone might know why it occurs? I have a page populated with dynamic controls. Ever time a postback occurs the controls are recreated with the same ids, before postback processing occurs, so that the controls are redisplayed with their values from the previous postback. (An aside: I'd be very interested to know how ASP.NET does this postback processing?). Before anyone comments, I am doing this because the page is too complicated to do any other way (I tried it using a repeater but got stuck once I started to building dynamic controls, including controls that generate events, within dynamic controls within a repeater!). It turned out to be easier to do this as a flat page of many dynamic controls and it does work. However, here was the strange behaviour. If I named a dynamic control, say a textbox with an id that contained a colon (:) any value I put in it is not kept across postbacks. If I replace the colon with an underscore (_) then the value is kept. So, why does the : cause a problem? Does it have some sort of special meaning for post-back processing? Regards, Matt Matt Daley Imutome Limited Bristol, United Kingdom matt.daley@imutome.com

      U Offline
      U Offline
      User 642242
      wrote on last edited by
      #2

      I'm not 100% sure on this, but it might help you out. I believe that : are used by the .Net Runtime when a control implements the INaming interface to ensure that all child controls have a unique id within the web page. Such as in the data grid control. The child control's uniqueId becomes ParentId:ChildId. When you use the : in your id, you may be confusing the .net runtime to try and look for a parent control that does not exist, so it never finds your control. HTH

      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