Hyperlink control

The HyperLink control creates links on a web page that allow users to move from page to page in your application. The HyperLink control can display clickable text or an image. Unlike most ASP.NET controls, the HyperLink control does not raise an event in server code when users click it. Instead, the control simply performs navigation.

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

  2. In the Tag Properties task pane, set properties for the control.

Common HyperLink control properties

Property

Description

Text

Specifies the text displayed as a hyperlink in the user's browser. You can include HTML formatting in the property.

CssClass

Specifies a style for the hyperlink. When you use the Microsoft® Expression® Web CSS tools to apply a style to the control, this property is automatically updated.

ImageUrl

Creates a graphical link when you set the property to the URL of a .gif, .jpg, or other web graphic file. If you set both the ImageUrl and Text properties, the ImageUrl property takes precedence.

href

Specifies the URL of the page to which you want to link.

Target

Indicates the ID of a target window or frame in which to display the linked page. You can either specify a window by name or use predefined target values, such as _top, _parent, and so on.

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

The primary advantage of using a HyperLink control is that you can set link properties in server code. For example, you can dynamically change the link text or target page based on conditions in your page.

Another advantage of using the HyperLink control is that you can use data binding to specify the target URL for the link (and parameters to be passed with the link, if necessary). A typical example is to create HyperLink controls based on a list of products; the target URL points to a page where the user can read more detail about the product.

Note

The URLs associated with a hyperlink can be tampered with by a malicious user. For more information, see How to: Protect in the MSDN library.

For more information about working with the HyperLink control, see HyperLink in the MSDN library.