Reputation: 3849
I have usercontrol with couple of buttons in it, I wanted to use the user control in page and instead of displaying the button which is on usercontrol I wanted to click a button on the page which raises button click event on the usercontrol.
PageA_Button_Click(object sender, EventArgs e) should call UserControl_Button_Click(object sender, EventArgs e)
public partial class UserControls_DEMO : System.Web.UI.UserControl
{
public void UserControl_Button_Click(object sender, EventArgs e)
{
}
}
public partial class ASPXPAGE : System.Web.UI.Page
{
protected void PageA_Button_Click(object sender, EventArgs e)
{
//Call UserControl_Button_Click here
}
}
Upvotes: 0
Views: 447
Reputation: 1299
Instead of making the first button's onclick event call the second buttons, I would just add this tag to the first button's HTML:
OnClientClick="document.getElementById('INSERT_SECOND_BUTTON_ID_HERE').click();"
Slightly different approach to what you are wanting to do.
Upvotes: 1