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
Solved

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

Posted on 2010-11-18
8
651 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

766 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