开发者

How to get event in another control event?

开发者 https://www.devze.com 2023-03-31 02:19 出处:网络
In my application, i am trying to get button_click event in another button click event, but it is not working.

In my application, i am trying to get button_click event in another button click event, but it is not working.

My code is,

protected voi开发者_开发技巧d btn1_Click(object sender, EventArgs e)
{
    Response.Write("hi.....");
}

protected void btn2_Click(object sender, EventArgs e)
{
    btn1.Click += new EventHandler(this.btn1_Click);
}

What is wrong with this?


I suppose you want to call the code of btn1_click event.

If this is the case, you simple call it as a method in your btn2_Click.

 protected void btn2_Click(object sender, EventArgs e)
 {
     btn1_Click (sender, e);
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消