开发者

How to get event in another control event?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜