ImageClickEventArgs Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Provides data for any events that occur when a user clicks an image-based ASP.NET server control, such as the HtmlInputImage or ImageButton server controls. This class cannot be inherited.

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

System.Object
  System.EventArgs
    System.Web.UI.ImageClickEventArgs

public sealed class ImageClickEventArgs : EventArgs

NameDescription
System_CAPS_pubmethodImageClickEventArgs(Int32, Int32)

Initializes a new instance of the ImageClickEventArgs class using the x and y parameters.

System_CAPS_pubmethodImageClickEventArgs(Int32, Int32, Double, Double)

Initializes a new instance of the ImageClickEventArgs class using the x, y, xRaw, and yRaw parameters.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldX

An integer that represents the x-coordinate where a user clicked an image-based ASP.NET server control.

System_CAPS_pubfieldXRaw

An integer that represents the raw x-coordinate where a user clicked an image-based ASP.NET server control.

System_CAPS_pubfieldY

An integer that represents the y-coordinate where a user clicked an image-based ASP.NET server control.

System_CAPS_pubfieldYRaw

An integer that represents the raw y-coordinate where a user clicked an image-based ASP.NET server control.

This class passes the location where a user clicked an HtmlInputImage server control or an ImageButton Web server control. Clicking an HtmlInputImage server control causes a ServerClick event to occur, while clicking an ImageButton server control causes a Click event to occur. You can then use event handlers to programmatically respond to the event based on the value of these coordinates.

System_CAPS_noteNote

The origin coordinates (0,0) are located at the upper left corner of the image.

Raising an event invokes the event handler through a delegate. For more information, see NIB: Raising an Event.

The following code example demonstrates an ASP.NET page that uses the information provided by this class to display the coordinates of a user's click on an image.

// 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() + ")";
}

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: