This documentation is archived and is not being maintained.

Page.ClientTarget Property

Gets or sets a value that allows you to override automatic detection of browser capabilities and to specify how a page renders for particular browser clients.

[Visual Basic]
Public Property ClientTarget As String
public string ClientTarget {get; set;}
public: __property String* get_ClientTarget();
public: __property void set_ClientTarget(String*);
public function get ClientTarget() : String;
public function set ClientTarget(String);

Property Value

A String that specifies the browser capabilities that you want to override.


If you do not set this property, the HttpBrowserCapabilities object associated with the Page.Request property reflects the capabilities of the client browser. If you set this property, client browser detection is disabled and the page will use browser capabilities associated with the user agent string that you define. You can set this property to any valid user agent string.

The configuration file (Machine.config) on your Web server computer defines four default aliases you can use as shorthand for common user agent strings. These defaults are ie5, which allows you to customize pages for Internet Explorer version 5.5 browsers, ie4, which allows you to customize pages for Internet Explorer version 4.0 browsers, uplevel, which allows you to customize pages for Internet Explorer 4.0 and later, and downlevel, which allows you to customize pages for browsers earlier than Internet Explorer 4.0.

You can set these user agent or alias strings programmatically using this property, or set them declaratively using the @ Page directive's clienttarget attribute. If you want to customize the response a page sends to browsers other than the four defaults, you have two choices. You can set the property to a complete valid user agent string, or define a new alias in the <clientTarget> section of the application-level configuration file (Web.config) and set this property to that alias. For more information, see ASP.NET Configuration.

The following example defines an ie302 alias and includes sections needed to configure your application in its Web.config file. Using this alias, you can set the ClientTarget property to ie302 and customize pages specifically for Internet Explorer version 3.02 browsers.

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


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

See Also

Page Class | Page Members | System.Web.UI Namespace