- Sep 29, 2000
- 70,150
- 5
- 0
What a PAIN IN THE ASS it is playing with dynamically created controls. I've got a page with a menu up top of dynamically created link buttons, which in turn fill a datagrid with yet more linkbuttons, and of course the paging for the datagrid is composed of linkbuttons.
Given that the handling for these has to occur prior to the end of page load, and the events of a linkbutton (or any control) occur AFTER the page_load, if you want to have a control's event create other controls and you expect them to be tied in with event handling, the only way is to have them set some flags or crap and then essentially reload your page, requiring another post back.
What I've done now is create a class within my page which has all of my form values (about 9 different search criteria). When a link button clicks it sets the class's properties with my form values, then just transfers back to the page where page load checks this class (which is stored in a session object).
I suppose my real problem here is that a linkbutton acts as a control, and not as a hyperlink with an onclick event (which you see a lot of pages use these days, so that you can set some hidden form fields on a page, then submit it, and then their values are available immediately on page load).
Given that the handling for these has to occur prior to the end of page load, and the events of a linkbutton (or any control) occur AFTER the page_load, if you want to have a control's event create other controls and you expect them to be tied in with event handling, the only way is to have them set some flags or crap and then essentially reload your page, requiring another post back.
What I've done now is create a class within my page which has all of my form values (about 9 different search criteria). When a link button clicks it sets the class's properties with my form values, then just transfers back to the page where page load checks this class (which is stored in a session object).
I suppose my real problem here is that a linkbutton acts as a control, and not as a hyperlink with an onclick event (which you see a lot of pages use these days, so that you can set some hidden form fields on a page, then submit it, and then their values are available immediately on page load).
