Reputation: 193
I have one form called Form 1 that has a button click event for button 1.
public partial class Form1: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//Some Code - If a user clicks me button 2 will be executed !
}
}
I have another form in other aspx page called Form 2 with the button button2.
public partial class Form2: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
//Some Code
}
}
So far so good, My question is how can i do, if a user click the button1 in Form1, button2 in Form 2 will be fired ?
Thanks !
Upvotes: 0
Views: 154
Reputation: 10014
If you are using JQuery you can do this:
$('#Button1').on('click', function () {
$('#Button2').click();
});
However, I would question why you cannot do this by sharing code instead.
Upvotes: 0
Reputation: 888117
You should move that code to a static function in a common class, then call that function from both handlers.
If you're reference controls on the other page, the whole question makes no sense.
Upvotes: 3