469,646 Members | 1,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

event from dynamically loaded usercontrol gets fired once for 2 clicks

Dan
hi,
i have a page with two usercontrols:
1. a static menu control.
2. a dynamically loaded control as user interface

the main page receives events from the menu and sets the apropriate
ui control in the OnBubbleEvent method.
but now, the ui control doesnt't fire any events any more. i first have
to do another postback, and now the ui fires again.
what's wrong there?
it seems to me that only if the actual usercontrol has been added in the
pageload method, the control somehow is asigned to the page.
if the uc gets added later (OnBubbleEvent), the conection seems to get lost.

here some code:

main page:
private void Page_Load(object sender, System.EventArgs e)
{
control=this.LoadControl("x");
this.FindControl("Form1").Controls.Add(control);
}

override protected bool OnBubbleEvent(object sender, System.EventArgs e)

{
int index=this.FindControl("Form1").Controls.IndexOf(c ontrol);
//if menu button has been clicked, load the apropriate uc:
control=this.LoadControl("x");
this.FindControl("Form1").Controls.RemoveAt(index) ;
this.FindControl("Form1").Controls.Add(control);
}

as soon as the control stems from the OnBubbleEvent, nothing gets fired.
when the button of the control gets clicked another time (postback)
and the pageload sets the actual control, everything is fine again.
so, the event fires only 50% of the click.
i don't understand that.

thanks very much for any help.
dan
Nov 18 '05 #1
0 1071

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gary Shell | last post: by
9 posts views Thread by Marcelo Cabrera | last post: by
6 posts views Thread by tshad | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.