Solved

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

Posted on 2010-11-18
8
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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
 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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