I created a Toolbar like server control which can contain multiple ToolbarItems. When the ToolbarItems (short items) are added dynamically in the OnInit or PageLoad event of the page the items are hooked up properly (items maintained between postbacks, server
click events work properly).
There is however a need to be able to add items dynamically outside of the above life cycle events. Say a button is clicked and in its Button_Click handler more items are added to the Toolbar. These "late" items are not showing up, which I do understand
why as they are added to the control too late and aren't wired up properly, but is there a workaround for this?
Please make sure that you've called something like Controls.Add(some new controls) in the event of page-LoadComplete in order to add more controls there.
Member
39 Points
136 Posts
maintaining dynamically created controls in custom server controls
Jul 09, 2012 09:05 AM|benjib98|LINK
Hi,
I created a Toolbar like server control which can contain multiple ToolbarItems. When the ToolbarItems (short items) are added dynamically in the OnInit or PageLoad event of the page the items are hooked up properly (items maintained between postbacks, server click events work properly).
There is however a need to be able to add items dynamically outside of the above life cycle events. Say a button is clicked and in its Button_Click handler more items are added to the Toolbar. These "late" items are not showing up, which I do understand why as they are added to the control too late and aren't wired up properly, but is there a workaround for this?
Star
9210 Points
2981 Posts
Re: maintaining dynamically created controls in custom server controls
Jul 09, 2012 10:59 AM|Mudasir.Khan|LINK
not very clear on you question
all the added controls are rendred and sent to client at one shot
All-Star
94120 Points
18111 Posts
Re: maintaining dynamically created controls in custom server controls
Jul 10, 2012 09:51 PM|Decker Dong - MSFT|LINK
Please make sure that you've called something like Controls.Add(some new controls) in the event of page-LoadComplete in order to add more controls there.