Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
I created a web user control which contains a dropDownList control.

ddlPatients.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ddlPatients.ascx.cs" Inherits="Admin_User_control_ddlPatients" %>

<asp:DropDownList ID="ddlCallsByPatient" runat="server" AutoPostBack="True" />



ddlPatients.ascx.cs

if (!Page.IsPostBack)

     BindDropDownLists();

And Drag And Drop it to aspx page.

Now I want to fire OnSelectedIndexChanged event to get the selected value of that dropDownList control in code behind.
Posted

in your web user control class define event
C#
public event EventHandler SelectionChanged_UserControl;
//use OnSelectionChanged event of dropDownList 

void Selection_Change(Object sender, EventArgs e) 
      {

      SelectionChanged_UserControl(sender,e);

      }

//you will get SelectionChanged_UserControl event where you use web control 
//this event will fire when selection of dropDownList changed 
 
Share this answer
 
its a simple solution

First in user control create a delegate above Page_Load() method

C#
public delegate void OnSelectedIndexchanged();
public event OnSelectedindexchanged Setactionname;


then in your dropdown selected index change add following line

SQL
if (Setactionname!= null)
                Setactionname();

then go to your ASPX page and
C#
UsercontrolName.Setactionname+= this.Mehtodnameonlocalpage;


create a function in your aspx code behind page and do what u need to do like
C#
private void SetSelectedActor()
    {

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900