HyperLink.Target HyperLink.Target HyperLink.Target HyperLink.Target Property

定義

取得或設定在按一下 HyperLink 控制項時顯示所連結之 Web 網頁內容的目標視窗或框架。Gets or sets the target window or frame in which to display the Web page content linked to when the HyperLink control is clicked.

public:
 property System::String ^ Target { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))]
[System.ComponentModel.Bindable(true)]
public string Target { get; set; }
member this.Target : string with get, set
Public Property Target As String

屬性值

目標視窗或框架,載入當按一下 HyperLink 控制項時所連結的 Web 網頁。The target window or frame to load the Web page linked to when the HyperLink control is clicked. 除了下列以底線為開頭的特殊值以外,該值必須以 A 到 Z (不區分大小寫) 範圍內的字母為開頭:Values must begin with a letter in the range of a through z (case-insensitive), except for the special values listed in the following table, which begin with an underscore.

_blank 在無框架的新視窗中呈現內容。Renders the content in a new window without frames.

_parent 在即時父代框架組中呈現內容。Renders the content in the immediate frameset parent.

_search 在搜尋窗格中呈現內容。Renders the content in the search pane.

_self 在擁有焦點 (Focus) 的框架中呈現內容。Renders the content in the frame with focus.

_top 在無框架的完整視窗中呈現內容。Renders the content in the full window without frames.


請查閱您的瀏覽器文件,以判斷是否支援 _search 值。Check your browser documentation to determine if the _search value is supported. 例如,Microsoft Internet Explorer 5.0 (含) 以後版本支援 _search 目標值。For example, Microsoft Internet Explorer 5.0 and later support the _search target value.

預設值為空字串 ("")。The default value is an empty string ("").

範例

下列範例示範如何設定Target屬性,以指定的視窗或框架,以顯示與相關聯的頁面HyperLink控制項。The following example demonstrates how to set the Target property to specify the window or frame to display the page associated with the HyperLink control.

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>HyperLink Sample</title>
</head>
<body>
<form id="Form1" runat="server">


   <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"/>       

</form>
</body>
</html>

<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>HyperLink Sample</title>
</head>
<body>
<form id="Form1" runat="server">

   <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"/>       

</form>
</body>
</html>

備註

使用Target屬性,以指定的框架或視窗顯示網頁的連結時HyperLink按一下控制項時。Use the Target property to specify the frame or window that displays the Web page linked to when the HyperLink control is clicked. 設定來指定網頁NavigateUrl屬性。The Web page is specified by setting the NavigateUrl property.

如果未設定這個屬性,瀏覽器或具有焦點的視窗會重新整理時HyperLink按一下控制項時。If this property is not set, the browser or window with focus refreshes when the HyperLink control is clicked.

注意

Target屬性會轉譯成target屬性。The Target property renders as a target attribute. target屬性上anchorXHTML 1.1 文件類型定義中不允許的項目。The target attribute on anchor elements is not allowed in the XHTML 1.1 document type definition. 未設定Target屬性如果轉譯的輸出,如HyperLink必須與 XHTML 1.1 相容。Do not set the Target property if the rendered output for the HyperLink must be XHTML 1.1 compliant. 如需詳細資訊,請參閱主題XHTML 標準,在 Visual Studio 及 ASP.NETFor more information, refer to the topic XHTML Standards in Visual Studio and ASP.NET.

在建立可存取網頁時,強烈建議您避免使用Target指向另一個視窗中的屬性。When creating accessible Web pages, it is strongly recommended you avoid using the Target property to target another window. 如需詳細資訊,請參閱 < 協助工具的 Visual Studio 及 ASP.NETASP.NET 控制項和協助工具For more information, see Accessibility in Visual Studio and ASP.NET and ASP.NET Controls and Accessibility.

適用於

另請參閱