共用方式為


How to: Add ImageButton Web Server Controls to a Web Forms Page

You can add an ImageButton Web server control to your Web Forms page when you want to display a picture, or image, as a hyperlink.

Note

To create an image with multiple clickable regions, you can use the ImageMap control. For details, see ImageMap Web Server Control Overview.

To add an ImageButton Web server control to a Web Forms page

  1. From the Standard tab of the Toolbox, drag an ImageButton Web server control onto the page.

  2. In the Appearance category of the Properties window, set the button's ImageUrl property to point to an image file (.gif, .jpg, and so on).

    Note

    Click the ellipsis (...) button in the ImageUrl property box to select an image using the Select Image dialog box.

    You can point to an image file anywhere by using a URL or UNC path.

    Security noteSecurity Note:

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

See Also

Tasks

How to: Determine Coordinates in an ImageButton Web Server Control