How to: Add HyperLink Web Server Controls to a Web Forms Page
You can add a hyperlink to your Web Forms page by placing a HyperLink Web 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
From the Standard tab of the Toolbox, drag a HyperLink control onto the page.
In the Appearance category of the Properties window, specify the format of the link on the page by doing one of the following:
To create a text link, set the control's Text property. 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's ImageUrl property to the URL of a .gif, .jpg, or other Web graphic file.
In the Navigation category of the Properties window, set the NavigateUrl property to the URL of the page to which you want to link.
Security Note: 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 Script Exploits Overview.
Optionally, in the Navigation category of the Properties window, specify the target by setting 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.
Note
You can change the appearance of the link text — for example, whether it is underlined — by using styles. For details, see ASP.NET Web Server Controls and CSS Styles.
The following example shows how you can set the properties of a HyperLink control at run time. The method handles a Button control's Click event and sets the control's link text and target page.
Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Hyperlink1.Text = "Home" Hyperlink1.NavigateUrl = "https://www.microsoft.com/net/" End Sub
protected void Button1_Click (object sender, System.EventArgs e) { this.HyperLink1.Text = "Home"; this.HyperLink1.NavigateUrl = "https://www.microsoft.com/net/"; }