• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

How to fire events(drop down selected index changed) in Dynamically Loaded user controls

i have 3 user controls which are loaded dynamically... can anyone help me how to fire events in a dynamically loaded controls.. none of the events are firing...
any examples.. please
0
gautam_reddyc
Asked:
gautam_reddyc
  • 4
  • 4
1 Solution
 
jasonduanCommented:
if you want help, post the code that creats the control.
0
 
gautam_reddycAuthor Commented:
jason,
   Here is the code..

UserControl uc = LoadControl("~/User Controls/t/UC1l.ascx") as UserControl;
                                Panel1.Controls.Add(uc);
0
 
gautam_reddycAuthor Commented:
the user control has drop down..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jasonduanCommented:
no problem for this piece of code.

Did you test your user control by put it to a page directly (without dynamic loading)?
0
 
jasonduanCommented:
Make sure you set "AutoPostBack=true" for the dropdown list control.
0
 
gautam_reddycAuthor Commented:
jason,
  Autopostback is true and i load usercontrols dynamically depending on the selected option.
loading to page directly is not an option
0
 
gautam_reddycAuthor Commented:
i have the following sample which loads the User control dynamically..\

UserControl uc = LoadControl("~/User Controls/t/UC1.ascx") as UserControl;
Panel1.Controls.Add(uc);

-- the usercontrol has dropdown and button whose events are not fired..
i tried to add the below code to fire the event using delegate..no luck

private void InitializeComponent()
{
this.ddl.SelectedIndexChanged += new System.EventHandler(ddlBranch_GetEmployee);

this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public event EventHandler BubbleClick;

protected void OnBubbleClick(EventArgs e)
{
if (BubbleClick != null)
{
BubbleClick(this, e);
}
}

0
 
jasonduanCommented:
I did not ask you load the user control to page directly. I suggest you to test the user control by putting it to page directly. This is part of the diagnostic process to help identify where the problem is. I've been dynamically loading user control in my projects, no problem at all. Just trying to help you to pinpoint the issue.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now