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.
benjib98
Member
85 Points
139 Posts
maintaining dynamically created controls in custom server controls
Jul 09, 2012 01:05 PM|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?
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: maintaining dynamically created controls in custom server controls
Jul 09, 2012 02:59 PM|LINK
not very clear on you question
all the added controls are rendred and sent to client at one shot
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: maintaining dynamically created controls in custom server controls
Jul 11, 2012 01:51 AM|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.