Export (0) Print
Expand All

HyperLink.Target Property

Gets or sets the target window or frame to display the Web page content linked to when the HyperLink control is clicked.

[Visual Basic]
Public Property Target As String
[C#]
public string Target {get; set;}
[C++]
public: __property String* get_Target();
public: __property void set_Target(String*);
[JScript]
public function get Target() : String;
public function set Target(String);

Property Value

The target window or frame to load the Web page linked to when the HyperLink control is clicked. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:

_blank Renders the content in a new window without frames.
_parent Renders the content in the immediate frameset parent.
_self Renders the content in the frame with focus.
_top Renders the content in the full window without frames.

The default value is String.Empty.

Remarks

Use the Target property to specify the frame or window that displays the Web page linked to when the HyperLink control is clicked. The Web page is specified by setting the NavigateUrl property.

If this property is not set, the browser or window with focus refreshes when the HyperLink control is clicked.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to set the Target property to specify the window or frame to display the page associated with the HyperLink.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <h3>HyperLink Sample</h3>

   Click on the HyperLink:<br>  

   <asp:HyperLink id="hyperlink1" 
                  ImageUrl="images/pict.jpg"
                  NavigateUrl="http://www.microsoft.com"
                  Text="Microsoft Official Site"
                  Target="_blank"
                  runat="server"/>       

</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <h3>HyperLink Sample</h3>

   Click on the HyperLink:<br>  

   <asp:HyperLink id="hyperlink1" 
                  ImageUrl="images/pict.jpg"
                  NavigateUrl="http://www.microsoft.com"
                  Text="Microsoft Official Site"
                  Target="_blank"
                  runat="server"/>       

</body>
</html>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

</head>
<body>

   <h3>HyperLink Sample</h3>

   Click on the HyperLink:<br>  

   <asp:HyperLink id="hyperlink1" 
                  ImageUrl="images/pict.jpg"
                  NavigateUrl="http://www.microsoft.com"
                  Text="Microsoft Official Site"
                  Target="_blank"
                  runat="server"/>       

</body>
</html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HyperLink Class | HyperLink Members | System.Web.UI.WebControls Namespace | NavigateUrl

Show:
© 2014 Microsoft