开发者

how to call an image button event in a function

i need to call an image button event in a function. how to call

 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

    }

this my function

 void  bindData()
{
// here i nee  to cal the  abov开发者_JAVA技巧e image button event
}

thank you


Try this to call your event with empty parameters :

void  bindData()
{
    ImageButton1_Click(null, new ImageClickEventArgs(0, 0));
}


Easy:

void bindData()
{
    // here i nee  to cal the  above image button event
    ImageButton1_Click(null, null);
}

You can also send in a control as the sender argument if you want to use it and you could also send in some arguements by sending in a n ImageClickEventArgs object but neither are necessary.


You can either use ImageButton1_Click(image, new ImageClickEventArgs(0, 0) where the image is the image you want to simulate the click event on. Or you can send in null parameters. But the best way is to create another method with the logic inside ImageButton1_Click and place a call to it inside the click event, and anywhere else that is necessary.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜