Page.ClientTarget Page.ClientTarget Page.ClientTarget Page.ClientTarget Property

定義

取得或設定數值,讓您覆寫瀏覽器能力的自動偵測,並指定網頁在特定瀏覽器用戶端要如何顯示。Gets or sets a value that allows you to override automatic detection of browser capabilities and to specify how a page is rendered for particular browser clients.

public:
 property System::String ^ ClientTarget { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public string ClientTarget { get; set; }
member this.ClientTarget : string with get, set
Public Property ClientTarget As String

屬性值

String,指定您要覆寫的瀏覽器能力。A String that specifies the browser capabilities that you want to override.

範例

下列程式碼範例會定義ie302別名並包含在其 Web.config 檔案中設定您的應用程式所需的各節。The following code example defines an ie302 alias and includes sections needed to configure your application in its Web.config file. 使用此別名,您可以設定ClientTarget屬性設ie302和自訂專為 Internet Explorer 3.02 和瀏覽器的頁面。Using this alias, you can set the ClientTarget property to ie302 and customize pages specifically for Internet Explorer 3.02 browsers.

<configuration>  
  <system.web>  
   <clientTarget>  
    <add alias="ie302" useragent="Mozilla/2.0 (compatible; MSIE 3.02; Windows NT 3.5)" />  
   </clientTarget>  
  </system.web>  
</configuration>  

備註

如果您未設定ClientTarget屬性,HttpBrowserCapabilities相關聯的物件Page.Request屬性會反映用戶端瀏覽器的功能。If you do not set the ClientTarget property, the HttpBrowserCapabilities object associated with the Page.Request property reflects the capabilities of the client browser. 如果您要設定這個屬性,已停用用戶端瀏覽器偵測和頁面會使用您提供的值 (別名) 相關聯的瀏覽器功能。If you do set this property, client browser detection is disabled and the page will use browser capabilities associated with the value (alias) that you provide.

Web 伺服器電腦上的根 Web.config 組態檔會定義下列的預設別名,您可以使用一般的使用者代理字串的簡略形式:The root Web.config configuration file on the Web server computer defines the following default aliases that you can use as shorthand for common user-agent strings:

  • uplevel表示瀏覽器功能相當於 Internet Explorer 6.0。uplevel, which specifies browser capabilities equivalent to Internet Explorer 6.0.

  • downlevel表示瀏覽器功能相當於舊的瀏覽器不支援用戶端指令碼。downlevel, which specifies browser capabilities equivalent to older browsers that do not support client script. 若要判斷網頁如何運作的瀏覽器已停用的用戶端指令碼中,您可以使用此別名。You can use this alias to determine how Web pages would work in a browser that has client script disabled.

您可以設定以程式設計方式使用這個屬性的別名,或是您可以設定它使用以宣告方式ClientTarget的屬性@ Page指示詞。You can set the alias programmatically using this property, or you can set it declaratively using the ClientTarget attribute of the @ Page directive.

您可以定義中的其他別名clientTarget應用程式層級 Web.config 檔案區段。You can define additional aliases in the clientTarget section of the application-level Web.config file. 如需詳細資訊,請參閱 < clientTarget 項目 (ASP.NET 設定結構描述)For more information, see clientTarget Element (ASP.NET Settings Schema).

適用於

另請參閱