How to: Add HyperLink Web Server Controls to a Web Forms Page
You can add a hyperlink to your Web Forms page by placing aWeb server control on the page and associating it with a URL. You can specify that HyperLink controls render as either text or as graphics.
To add a HyperLink Web server control to a Web Forms page
<asp:HyperLink>element to the page. For syntax, see .
Specify the format of the link in the page by doing one of the following:
To create a text link, set the control'sproperty. You can include HTML formatting in the property. For example, you can format an individual word in the text as bold by placing a
<B>tag around it in the Text property.
To create a graphical link, set the control'sproperty 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.
Set theproperty to the URL of the page to which you want to link.
The URL that is associated with a hyperlink points to an external resource. If you point to a resource that you do not own, be sure it is safe for your users to work with. For more information, see.
Optionally, set 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
_parent, and so on.
You can change the appearance of the link text — for example, whether it is underlined — by using styles. For details, see.
The following example shows how you can set the properties of a HyperLink control at run time. The method handles acontrol's event and sets the control's link text and target page.
Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button1.Click Hyperlink1.Text = "Home" Hyperlink1.NavigateUrl = "http://www.contoso.com" End Sub