Mark Sisson wrote:
> Good afternoon all.
> I am creating a usercontrol (*.ascx) with a Calendar control on it.
> In the Calendar's DayRender event I'm dynamically adding ImageButton
> controls to cells on the calendar. For each of these image button I'm
> hooking up a click event as so:
>
> imgButton.Click += new ImageClickEventHandler(this.ImageButton_Click);
>
> Problem is that when the user clicks on the image button my event
> handler never fires. Now I think I know the reason but I don't know
> the best solution. Since the controls are added too late in the page
> lifecycle they aren't available when the postback happens so they
> never get called. So how do I create all these ImageButton's so that
> they can receive events on post back?
>
> I've heard about bubbling events but I'm not sure how they work.
> Could I a add control to my Calendar in it's DayRender event and tell
> the Framework to have it's click-event be sent to the Calendar's click
> event???????
>
> tia
I would suggest that on postback, you recreate the calendar in
exactly the same way as before the postback.
Then the events will fire normally.
In the event handler, you can destroy everything again and
build the final page.
--
Jos
|