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).

適用於

另請參閱