Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Different browsers, and different versions of the same browsers, support different features. ASP.NET server controls will automatically determine the level of browser that has requested the .aspx page and format the HTML it generates correctly for that browser. However, some control features cannot be rendered on older browsers, so it is a good idea to look at the output of your pages on as many browser types as you can to make sure that the pages are presented to all browsers the way you want them to be.
By default, the ASP.NET page framework determines browser capabilities by reading the user-agent information passed from the browser to the server during a request. (This information is available as the UserAgent property of the HttpRequest object.) The page matches the user-agent information against agent entries in the application, site, or machine configuration (.config) file. When the page finds a match between the current user-agent information and user agents listed in the file, it can read the corresponding browser capabilities, such as whether the browser supports scripting, styles, frames, and so on. Based on these capabilities, the controls on the page render Web controls using either uplevel (CSS-compliant) or downlevel (non-CSS) HTML elements.
If you want to explicitly control how the page is rendered — instead of relying on automatic browser detection — you can set the page's ClientTarget property. You can do this in the Property window or in HTML view. The property setting is stored as an attribute of the @ Page directive for that page.
The value of the ClientTarget property is an alias for the type of browser you want to render for. By default, the following aliases are available:
The above aliases are defined in the <clientTarget> element of the machine.config file for the server and map to specific user-agent information. For example, the alias "ie5" is mapped to the user-agent information that is normally returned by Internet Explorer 5.
By specifying "downlevel," you can force the page to render HTML 3.2-compatible elements no matter what browser has requested the page. Similarly, by specifying "ie5," you can force the page to render CSS style attributes even for downlevel browsers.
You can create additional aliases by defining them in the machine.config or Web.config file, which enables you to create custom browser definitions. For more information, see ASP.NET Settings Schema.
Note The page's ClientTarget property allows you to specify how the page is rendered at run time, but it is not used at design time in the Visual Studio Web Forms Designer. To specify a browser type for generating HTML elements, validating HTML, and providing the appropriate HTML choices for statement completion, set the page's targetSchema property.
Some functionality of ASP.NET server controls depends on being able to run client script. The client script is automatically generated and sent as part of the page, if the browser is capable of executing script. Even so, some users might have turned off script execution in their browsers, and will therefore not be able to fully use the control's capabilities. For more information, see Client Script in Web Forms Pages.
Browsers and client devices are split into two distinctive groups: uplevel and downlevel. These groups define the type of native support a browser or client device offers, and they generally determine the presentation and behavior of a loading page from a Web server.
Browsers and client devices that are considered uplevel usually support at least the following:
Downlevel browsers and client devices support the following only:
The following server control properties render differently in uplevel and downlevel browsers:
Detecting Browser Types in Web Forms | Programming Web Forms
Please sign in to use this experience.
Sign in