Question: I have save button on a dynamic usercontrol that I load onto aspx page, but I want to move the button onto .aspx page instead. How can I fire the onclick event from aspx to ascx. 

Any help would be great.

Cheers.

Code Example:

ascx:

```
   protected void BT_Save_Click(object sender, EventArgs e)
{//Save details currently on ascx page }

```

aspx:

```
 protected void BT_aspx_Click(object sender, EventArgs e)
{
//when this button is clicked I need it to fire BT_Save_Click on ascx page to save the data
}

```

Answer: 
In user control

```
<asp:Button ID="Button1" runat="server" Text="Button"  OnClick="Button1_Click"/>

```

In User control .cs page

```
public event EventHandler ButtonClickDemo;
protected void Button1_Click(object sender, EventArgs e)
{
    ButtonClickDemo(sender, e);
}

```

In Page aspx page

```
<uc1:WebUserControl runat="server" id="WebUserControl" />

```

In Page.cs 

```
protected void Page_Load(object sender, EventArgs e)
{
    WebUserControl.ButtonClickDemo += new EventHandler(Demo1_ButtonClickDemo);
}

protected void Demo1_ButtonClickDemo(object sender, EventArgs e)
{
    Response.Write("It's working");
}

```
You'll need to create a custom event on your ascx user control and subscribe it within your aspx page.

have a look at this question

[define Custom Event for WebControl in asp.net](https://stackoverflow.com/questions/10696651/define-custom-event-for-webcontrol-in-asp-net)