Click here to Skip to main content
15,910,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a User control which contains a drop down. This user control is placed on the web form. Now I have to use selectionIndexChanged event which is there in dropdown events from the page . How can I solve this issue ??? Plase help
Posted
Updated 27-Jun-12 23:57pm
v2
Comments
Sandeep Mewara 28-Jun-12 6:34am    
Not clear.
You have a dropdown and any event of it can be defined in page behind. What is the issue?
sagar wasule 28-Jun-12 6:38am    
Thanks for reply.
I have drop down in Usercontrol but when I have to use Selected Index changed event of that dropdown it doesn't work . How to acces the event present in the drop down

1 solution

How to handle event for user control in asp.net page[^]

C#
public partial class Test : System.Web.UI.UserControl

{

public event EventHandler buttonClick;

 protected void Button1_Click(object sender, EventArgs e)
    {
        buttonClick(sender, e);
    }

}

Then you can subscribe the event buttonClick at webpage to display the different information .

public partial class Test: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    UserControlID.buttonClick+=new EventHandler(UserControlID_buttonClick);

}

    protected void UserControlID_buttonClick(object sender, EventArgs e)
    {
        Response.Write("hello,I am jack.");
    }

}
 
Share this answer
 
v2

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