Ler em inglês Editar

Compartilhar via


ControlAdapter.Browser Property

Definition

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

C#
protected System.Web.HttpBrowserCapabilities Browser { get; }

Property Value

An HttpBrowserCapabilities specifying client browser and markup capabilities.

Examples

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.

C#
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.
        }
    }
}

Remarks

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.

Applies to

Produto Versões
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also