Export (0) Print
Expand All

ImageButton control

An ImageButton control allows you to present a picture as a clickable control.

Cc295482.alert_note(en-us,Expression.10).gifNote:

If you want to create an image with clickable regions, you can use the ImageMap control.

When a user clicks an ImageButton, a form is submitted to the server. This causes the web page to be processed and any pending events to be raised in server-based code. For details about writing code for button controls, including ImageButton controls, see Button Web Server Controls Overview in the MSDN library.

To add an ImageButton control to a page

  1. Drag the ImageButton control from the Toolbox task pane to your page.

  2. Set properties that determine the ImageButton's appearance and behavior in the Tag Properties task pane.

Common ImageButton Properties

Property

Description

ImageUrl

The path to the image that is displayed in the ImageButton control.

AlternateText

The text that is displayed when the image cannot be displayed.

For a full description of all ImageButton control properties, see ImageButton in the MSDN library.

Cc295482.alert_note(en-us,Expression.10).gifNote:

The URL associated with an ImageButton control can be tampered with by a malicious user. For more information, see How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings in the MSDN library.

When users click an ImageButton control, a parameter passed to the event handler for the control's Click event includes the coordinates indicating where the user clicked. This allows you to perform different tasks based on where the user clicked. Coordinate information is sent as part of the event-argument object for the ImageButton control's Click event. For information on managing this coordinate information in code, see How to: Determine Coordinates in an in the MSDN library.

Community Additions

ADD
Show:
© 2014 Microsoft