Browser Property
Collapse the table of content
Expand the table of content

ControlAdapter.Browser Property

Gets a reference to the browser capabilities of the client making the current HTTP request.

Namespace: System.Web.UI.Adapters
Assembly: System.Web (in system.web.dll)

protected HttpBrowserCapabilities Browser { get; }
/** @property */
protected HttpBrowserCapabilities get_Browser ()

protected function get Browser () : HttpBrowserCapabilities

Not applicable.

Property Value

An HttpBrowserCapabilities specifying client browser and markup capabilities.

A ControlAdapter object determines the client browser capabilities from the HttpBrowserCapabilities object that is returned by the Browser property. This enables the ControlAdapter object to render browser-specific markup or otherwise modify the behavior of the Control.

The following code example shows how to use the Browser property to access the details of the requesting browser. In this example, the code checks to determine whether the browser is compatible with JavaScript, and then allows the developer to render customized output in that case.

using System;
using System.Web.UI;
using System.Web.UI.Adapters;

public class CustomControlAdapter : ControlAdapter
{
    protected override void Render( HtmlTextWriter writer )
    {
        // Access Browser details through the Browser property.
        Version jScriptVersion = Browser.JScriptVersion;

        // Test if the browser supports Javascript.
        if (jScriptVersion != null)
        {
            // Render JavaScript-aware markup.
        }
        else
        {
            // Render scriptless markup.
        }
    }
}


package BrowserProperty; 

import System.*;
import System.Web.UI.*;
import System.Web.UI.Adapters.*;

public class CustomControlAdapter extends ControlAdapter
{
    public void Render(HtmlTextWriter writer)
    {
        // Access Browser details through the base control.
        int ClientVersion = System.Convert.ToInt32(super.get_Browser().
            get_Version());
        if (ClientVersion > 1) {
            // Render output appropriate to these versions.
        }
    } //Render
} //CustomControlAdapter 

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2016 Microsoft