Export (0) Print
Expand All

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 ReadOnly Property Browser As HttpBrowserCapabilities

Property Value

Type: System.Web.HttpBrowserCapabilities
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.

Imports System
Imports System.Web.UI
Imports System.Web.UI.Adapters

Public Class CustomControlAdapter
    Inherits ControlAdapter

    Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

        ' Access Browser details through the Browser property. 
        Dim jScriptVersion As Version = Browser.jScriptVersion

        ' Test if the browser supports Javascript. 
        If Not (jScriptVersion Is Nothing) Then 
            ' Render JavaScript-aware markup. 
            ' Render scriptless markup. 
        End If 

    End Sub 'Render 

End Class 'CustomControlAdapter

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft