![]() ![]() | ||
You use the HyperLink control to create a link to another Web page, which can be a page in your Web application, or a page anywhere on the World Wide Web. You can specify the location of the linked page in an absolute way, where you use the linked page's complete URL, or in a relative way, with respect to the current page. You can see both types of links in Figure 17.6, in the HyperLinks example on the CD-ROM; in this example, I've created hyperlinks both to the Visual Basic technical page at Microsoft (using an absolute URL: http://msdn.microsoft.com/vbasic/technical/articles.asp) and to another Web form in the same project (using a relative URL: WebForm2.aspx).
Tip |
If terms like absolute and relative URLs are confusing to you, you might want to take a look at an HTML book like the Coriolis HTML Black Book. |
The text in the hyperlink control is specified with the Text property. You also can display an image as specified by the ImageUrl property.
Tip |
If both the Text and ImageUrl properties are set, the ImageUrl property is used. If the image is not available, the text in the Text property is displayed. Also, in browsers that support tool tips, the Text property also becomes the tool tip. |
You set the URL that the link navigates to with the NavigateUrl property. And there's more to the story than that; you also need to consider how you want to set the Target property. The link target specifies where the new content will be displayed; by default, when you click a hyperlink control, the linked-to content appears in a new browser window. You can set the Target property to the name of a window or frame (you set those names in HTML), or one of these values (which are HTML constants):
_blank— Displays the linked content in a new window without frames.
_parent— Displays the linked content in the immediate frameset parent.
_self— Displays the linked content in the frame with focus.
_top— Displays the linked content in the full window without frames.
Tip |
You also can customize the appearance of hyperlinks in a page by setting that page's link, alink, and vlink properties in the properties window. See "Setting Hyperlink Colors" in Chapter 14. |
The HTML to support hyperlinks is, of course, the <a> element; here's the HTML for the two hyperlinks you see in Figure 17.6:
<a id="HyperLink1" href="http://msdn.microsoft.com/vbasic/technical/_
articles.asp"
target="_self" style="Z-INDEX: 101; LEFT: 196px; POSITION:
absolute; TOP: 80px">VB.NET Tech Info</a>
⋮
<a id="HyperLink2" href="/HyperLinks/WebForm2.aspx"
target="_blank" style="Z-INDEX: 103; LEFT: 198px; POSITION:
absolute; TOP: 122px">Web Form 2</a>
<span id="Label1" style="Z-INDEX: 102; LEFT: 98px; POSITION:
absolute; TOP: 80px">Absolute URL:</span>
![]() ![]() | ||