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. General Programming
  3. .NET (Core and Framework)
  4. .NET ASPX page life cycle

.NET ASPX page life cycle

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdatabasesysadminquestionlearning
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.
  • O Offline
    O Offline
    Oskars
    wrote on last edited by
    #1

    I am very confused by .NET ASPX page processing model. I am using C# and creating simple database data dependant dynamic form with bunch of generated buttons. After that I am catching server side processed standard onclick events on these buttons and in onclick event function creating some other dynamic elements such as textboxes and other buttons. When I am pressing on new one created buttons generated outside page_load function - page reloads and these elements (of course) is lost! Now I am using some sick mytype in Session wich holds my dynamic cotrols and restores them by page_load. I suppose this is not the recommended way to do things (but for now) it works very well, maybe there is some logic and normal way to hold dynamically created elements in page. And I am wandering why .NET guys destroys page instance on each event?

    T 1 Reply Last reply
    0
    • O Oskars

      I am very confused by .NET ASPX page processing model. I am using C# and creating simple database data dependant dynamic form with bunch of generated buttons. After that I am catching server side processed standard onclick events on these buttons and in onclick event function creating some other dynamic elements such as textboxes and other buttons. When I am pressing on new one created buttons generated outside page_load function - page reloads and these elements (of course) is lost! Now I am using some sick mytype in Session wich holds my dynamic cotrols and restores them by page_load. I suppose this is not the recommended way to do things (but for now) it works very well, maybe there is some logic and normal way to hold dynamically created elements in page. And I am wandering why .NET guys destroys page instance on each event?

      T Offline
      T Offline
      TylerBrinks
      wrote on last edited by
      #2

      The Page object has a bool IsPostBack property. Put your form loading code inside an "if" statement only if IsPostBack is false.

      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