I’ve got an aspx file, and rendered within it is an ascx control.
The aspx file has a button, that, when clicked, fires an event.
I’ve got a button in the ascx control that I’d like to hook up to that same event…but I’m not clear on how to do it. I’m obviously missing something fairly elementary.
I was thinking it would be something like this:
myButton.Click += new EventHandler(btn_Click);
...
void btn_Click(object sender, EventArgs e)
{
<some way to get ahold of the parent aspx>.btn_Click(sender, e)
}
But, I’ve had no luck thus far, which makes me wonder if I’m barking up the wrong tree.
Ideas?
You need to create an event handler in the user control, like this:
ASCX markup:
ASCX code-behind:
In the page:
In the code behind of the page: