Export (0) Print
Expand All

ImageClickEventArgs Class

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

For a list of all members of this type, see ImageClickEventArgs Members.

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

[Visual Basic]
NotInheritable Public Class ImageClickEventArgs
   Inherits EventArgs
[C#]
public sealed class ImageClickEventArgs : EventArgs
[C++]
public __gc __sealed class ImageClickEventArgs : public EventArgs
[JScript]
public class ImageClickEventArgs extends EventArgs

Thread Safety

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

Remarks

This class passes the location where a user clicked on 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.

Note   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 Raising an Event.

Example

[Visual Basic, C#, JScript] The following 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.

[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

ImageClickEventArgs Members | System.Web.UI Namespace | Raising an Event | ImageClickEventHandler | Events and Delegates

Show:
© 2015 Microsoft