0
votes

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
    }
}   
1
I'm not quite sure I follow - could you post some code to describe what you are trying to do?David Brunow
see the original post.I just edited.CoolArchTek
I'm still a little confused - can you not just put UserControl_Button_Click(sender, e) inside of PageA_Button_Click?David Brunow

1 Answers

1
votes

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.