C#一个事件中调用另一个事件

为ImageButton1注册事件
protected void Page_Load(object sender, EventArgs e)
{
    ImageButton1.Click += new ImageClickEventHandler(Button1_Click);
}
protected void Button1_Click(object sender, EventArgs e)
{
    ClientScript.RegisterStartupScript(this.GetType(), "script", "alert('You Clicked the button');", true);
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
     string strValue = "ABC";
}
这样,点击ImageButton1之后就会同时执行 ImageButton1_Click和Button1_Click两个事件

你可能感兴趣的:(C#)