AdRotator.Target 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當點擊控制項時,會取得或設定顯示網頁 AdRotator 內容的瀏覽器視窗或框架名稱。
public:
property System::String ^ Target { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))]
public string Target { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))>]
member this.Target : string with get, set
Public Property Target As String
屬性值
顯示網頁內容的瀏覽器視窗或框,連結到點擊控制項時 AdRotator 的畫面。 預設值為空字串(“”),用於聚焦刷新視窗或框架。
- 屬性
範例
以下程式碼範例示範如何使用該 Target 屬性。 它會顯示當控制項在新的未框視窗中點擊時所連結 AdRotator 的網頁內容。
<%@ 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 runat="server">
<title>AdRotator Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
Target="_self"
AdvertisementFile="~/App_Data/Ads.xml"/>
</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 runat="server">
<title>AdRotator Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
Target="_self"
AdvertisementFile="~/App_Data/Ads.xml"/>
</form>
</body>
</html>
以下程式碼範例展示了包含廣告資訊的 XML 檔案格式。 欲了解更多檔案格式資訊,請參閱成員說明 AdvertisementFile 。
<Advertisements>
<Ad>
<ImageUrl>~/Images/image1.jpg</ImageUrl>
<Height>60</Height>
<Width>190</Width>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Microsoft Main Site</AlternateText>
<Impressions>80</Impressions>
<Keyword>Topic1</Keyword>
<Caption>This is the caption for Ad#1</Caption>
</Ad>
<Ad>
<ImageUrl>~/Images/image2.jpg</ImageUrl>
<Height>90</Height>
<Width>90</Width>
<NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>
<AlternateText>Wingtip Toys</AlternateText>
<Impressions>80</Impressions>
<Keyword>Topic2</Keyword>
<Caption>This is the caption for Ad#2</Caption>
</Ad>
</Advertisements>
備註
使用該 Target 屬性指定點擊控制項時,顯示網頁 AdRotator 內容的目標視窗或框架。
Note
該 Target 屬性以屬性形式呈現 target 。 XHTML 1.1 不允許在錨點target元素上a設定屬性() 因此,如果渲染的標記必須符合 XHTML 標準或無障礙標準,則不要設定該 Target 屬性。 欲了解更多資訊,請參閱 Visual Studio 中的 XHTML 標準及Visual Studio 與 ASP.NET 中的 ASP.NET 與無障礙。
Target值必須以 A 到 Z 範圍內的字母開頭(不區分大小寫),但以下特殊值以底線開頭。
| 目標值 | Description |
|---|---|
_blank |
它會在一個沒有框架的新視窗中渲染內容。 |
_parent |
將內容渲染到直接的框架集父節點。 |
_search |
在搜尋窗格中呈現內容。 |
_self |
能在畫面中聚焦渲染內容。 |
_top |
能在完整視窗中渲染內容,且不包含框架。 |
Note
請查看瀏覽器文件,確認該 _search 數值是否被支援。 例如,Internet Explorer 5.0 或更新版本支援目標值。_search