System.Web.UI.WebControls.ImageButton.OnClick Method

Raises the ImageButton.Click event and allows you to handle the ImageButton.Click event directly.

Syntax

protected virtual void OnClick (System.Web.UI.ImageClickEventArgs e)

Parameters

e
A System.Web.UI.ImageClickEventArgs that contains the event data.

Remarks

The ImageButton.Click event is raised when the System.Web.UI.WebControls.ImageButton control is clicked. By using the ImageButton.OnClick(System.Web.UI.ImageClickEventArgs) event handler, you can programmatically determine the coordinates where the image is clicked. You can then code a response, based on the values of these coordinates. Note that the origin (0, 0) is located at the upper left corner of the image.

Raising an event invokes the event handler through a delegate. For more information, see How to: Consume Events in a Web Forms Application.

The ImageButton.OnClick(System.Web.UI.ImageClickEventArgs) method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0