This documentation is archived and is not being maintained.

ImageClickEventHandler Delegate

Represents the method that will handle any events that are raised when a user clicks on an image-based ASP.NET server control.

[Visual Basic]
<Serializable>
Public Delegate Sub ImageClickEventHandler( _
   ByVal sender As Object, _
   ByVal e As ImageClickEventArgs _
)
[C#]
[Serializable]
public delegate void ImageClickEventHandler(
   object sender,
   ImageClickEventArgs e
);
[C++]
[Serializable]
public __gc __delegate void ImageClickEventHandler(
   Object* sender,
   ImageClickEventArgs* e
);

[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [Visual Basic, C#, C++]

The declaration of your event handler must have the same parameters as the ImageClickEventHandler delegate declaration.

sender
The server control that is the source of the event.
e
An ImageClickEventArgs object that contains event data.

Remarks

This delegate defines the required signature for all click events raised when a user clicks on an image-based ASP.NET server control. You must use the signature defined by this delegate for any OnServerClick event handlers that you create for an HtmlInputImage server control or any OnClick event handlers that you create for an ImageButton Web server control.

If you create a custom image-based ASP.NET server control that users can click, use this delegate to define the events associated with that user action. For more information, see Defining an Event.

For more information about delegates and how they interact with events, see Events and Delegates. For information about how to raise events, see Raising an Event.

Example

[Visual Basic] 
' Define the event handler that uses coordinate information through ImageClickEventArgs.
Sub ImageButton_Click(sender As Object, e As ImageClickEventArgs) 
   Label1.Text = "You clicked the ImageButton control at the coordinates: (" & _ 
                 e.X.ToString() & ", " & e.Y.ToString() & ")"
End Sub

[C#] 
// Define the event handler that uses coordinate information through ImageClickEventArgs.
void ImageButton_Click(object sender, ImageClickEventArgs e) 
{
   Label1.Text = "You clicked the ImageButton control at the coordinates: (" + 
                 e.X.ToString() + ", " + e.Y.ToString() + ")";
}

[JScript] 
// Define the event handler that uses coordinate information through ImageClickEventArgs.
function ImageButton_Click(sender, e : ImageClickEventArgs) 
{
   Label1.Text = "You clicked the ImageButton control at the coordinates: (" + 
                 e.X.ToString() + ", " + e.Y.ToString() + ")";
}

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web (in System.Web.dll)

See Also

System.Web.UI Namespace | ImageClickEventArgs | Raising an Event | Events and Delegates | ImageButton | HtmlImage | Defining an Event

Show: