views:

36

answers:

2

Hi, I have a Custom Cntrol that has a button inside it. Now I want to access the button click from my Application Page.

A: 

You have 2 ways:

You can access the button's click event through the user control object. For eg.

MyUC.button1.click += //etc

You can create your custom event of that specific button click in the user control. For example, in your usercontrol, you have:

public delegate void OnButtonClick(object sender, EventArgs e);

public event OnButtonClick Button1Click;


button1_click(object sender, EventArgs e)
{
    if(Button1Click != null) 
       Button1Click(this, e);

}

Then you watch for that event on your user control:

MyUC.Button1Click += //etc.
Shawn Mclean