Solved

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

Posted on 2010-11-18
8
647 Views
Last Modified: 2012-05-10
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
Comment
Question by:gautam_reddyc
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:jasonduan
ID: 34166959
if you want help, post the code that creats the control.
0
 

Author Comment

by:gautam_reddyc
ID: 34167494
jason,
   Here is the code..

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

Author Comment

by:gautam_reddyc
ID: 34167499
the user control has drop down..
0
 
LVL 11

Expert Comment

by:jasonduan
ID: 34167586
no problem for this piece of code.

Did you test your user control by put it to a page directly (without dynamic loading)?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:jasonduan
ID: 34167591
Make sure you set "AutoPostBack=true" for the dropdown list control.
0
 

Author Comment

by:gautam_reddyc
ID: 34167828
jason,
  Autopostback is true and i load usercontrols dynamically depending on the selected option.
loading to page directly is not an option
0
 

Author Comment

by:gautam_reddyc
ID: 34167831
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
 
LVL 11

Accepted Solution

by:
jasonduan earned 500 total points
ID: 34168011
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now