Export (0) Print
Expand All

PageAdapter Class

Adapts a Web page for a specific browser and provides the base class from which all page adapters inherit, directly or indirectly.

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

public abstract class PageAdapter : ControlAdapter

The PageAdapter type exposes the following members.

  NameDescription
Protected methodPageAdapterInfrastructure. Initializes a new instance of the PageAdapter class.
Top

  NameDescription
Protected propertyBrowserGets a reference to the browser capabilities of the client making the current HTTP request. (Inherited from ControlAdapter.)
Public propertyCacheVaryByHeadersGets a list of additional HTTP headers by which caching is varied for the Web page to which this derived page adapter is attached.
Public propertyCacheVaryByParamsGets a list of additional parameters from HTTP GET and POST requests by which caching is varied for the Web page to which this derived page adapter is attached.
Protected propertyClientStateGets an encoded string that contains the view and control states data of the Web page to which this derived page adapter is attached.
Protected propertyControlGets a reference to the control to which this control adapter is attached. (Inherited from ControlAdapter.)
Protected propertyPageGets a reference to the page where the control associated with this adapter resides. (Inherited from ControlAdapter.)
Protected propertyPageAdapterGets a reference to the page adapter for the page where the associated control resides. (Inherited from ControlAdapter.)
Top

  NameDescription
Protected methodBeginRenderCalled prior to the rendering of a control. In a derived adapter class, generates opening tags that are required by a specific target but not needed by HTML browsers. (Inherited from ControlAdapter.)
Protected methodCreateChildControlsCreates the target-specific child controls for a composite control. (Inherited from ControlAdapter.)
Public methodDeterminePostBackModeDetermines whether the Web page is in postback and returns a name/value collection of the postback variables.
Public methodDeterminePostBackModeUnvalidatedReturns a name-value collection of data that was posted to the page using either a POST or a GET command, without performing ASP.NET request validation on the request.
Protected methodEndRenderCalled after the rendering of a control. In a derived adapter class, generates closing tags that are required by a specific target but not needed by HTML browsers. (Inherited from ControlAdapter.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodGetPostBackFormReferenceReturns a DHTML code fragment that the client browser can use to reference the form on the page that was posted.
Public methodGetRadioButtonsByGroupRetrieves a collection of radio button controls specified by groupName.
Public methodGetStatePersisterReturns an object that is used by the Web page to maintain the control and view states.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodLoadAdapterControlStateLoads adapter control state information that was saved by SaveAdapterControlState during a previous request to the page where the control associated with this control adapter resides. (Inherited from ControlAdapter.)
Protected methodLoadAdapterViewStateLoads adapter view state information that was saved by SaveAdapterViewState during a previous request to the page where the control associated with this control adapter resides. (Inherited from ControlAdapter.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnInitOverrides the OnInit method for the associated control. (Inherited from ControlAdapter.)
Protected methodOnLoadOverrides the OnLoad method for the associated control. (Inherited from ControlAdapter.)
Protected methodOnPreRenderOverrides the OnPreRender method for the associated control. (Inherited from ControlAdapter.)
Protected methodOnUnloadOverrides the OnUnload method for the associated control. (Inherited from ControlAdapter.)
Public methodRegisterRadioButtonAdds a radio button control to the collection for a specified radio button group.
Protected methodRenderGenerates the target-specific markup for the control to which the control adapter is attached. (Inherited from ControlAdapter.)
Public methodRenderBeginHyperlink(HtmlTextWriter, String, Boolean, String)Renders an opening hyperlink tag that includes the target URL to the response stream.
Public methodRenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String)Renders an opening hyperlink tag that includes the target URL and an access key to the response stream.
Protected methodRenderChildrenGenerates the target-specific markup for the child controls in a composite control to which the control adapter is attached. (Inherited from ControlAdapter.)
Public methodRenderEndHyperlinkRenders a closing hyperlink tag to the response stream.
Public methodRenderPostBackEvent(HtmlTextWriter, String, String, String, String)Renders a postback event into the response stream as a hyperlink, including the encoded and possibly encrypted view state, and event target and argument.
Public methodRenderPostBackEvent(HtmlTextWriter, String, String, String, String, String, String)Renders a postback event into the response stream as a hyperlink, including the encoded and possibly encrypted view state, an event target and argument, a previous-page parameter, and an access key.
Protected methodRenderPostBackEvent(HtmlTextWriter, String, String, String, String, String, String, Boolean)Renders a postback event into the response stream as a hyperlink, including the encoded view state, an event target and argument, a previous-page parameter, and an access key.
Protected methodSaveAdapterControlStateSaves control state information for the control adapter. (Inherited from ControlAdapter.)
Protected methodSaveAdapterViewStateSaves view state information for the control adapter. (Inherited from ControlAdapter.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTransformTextTransforms text for the target browser.
Top

The PageAdapter class is an abstract class that adapts a Web page for a specific class of browsers, defined by the markup language that the browser uses (for example, HTML or XHTML). Much of the adaptability in rendering behavior can be encapsulated in the specialized text writer classes that derive from the HtmlTextWriter class, so it is not always necessary to provide a page adapter.

Most members of derived page adapters are called from the Page class or from control adapters. First, the Page class or control adapters detect the presence of the derived page adapter, and then call the member, or provide the functionality if the page adapter is not present.

The members of the PageAdapter class provide the following functionality:

  • The CacheVaryByHeaders and CacheVaryByParams properties define additional HTTP headers and HTTP GET and POST parameters that can be used to vary caching. They are called during cache initialization from the Page class.

  • The GetStatePersister method returns an object that can be used to persist the combined view and control states of the page. It is referenced from the PageStatePersister property if a derived page adapter is present.

  • The GetPostBackFormReference method provides a DHTML code fragment that can be used to reference forms in scripts.

  • The DeterminePostBackMode method returns a collection of the postback variables if the page is in postback. It is called by the .NET Framework instead of the Page.DeterminePostBackMode method if a derived page adapter is present.

  • The RenderBeginHyperlink and RenderEndHyperlink methods are used by control adapters to render hyperlinks if a derived page adapter is present.

  • The RenderPostBackEvent() method renders a hyperlink or postback client tag that can submit the form.

  • The RegisterRadioButton and GetRadioButtonsByGroup methods are used by radio button control adapters to reference the other RadioButton controls in a radio button group.

  • The ClientState property provides access to the combined control and view states of the Page object through the internal ClientState property of the Page class.

  • The TransformText method is used by control adapters to perform device-specific text transformation.

The following code example demonstrates how to derive a class named CustomPageAdapter from the PageAdapter class and override the RenderBeginHyperlink method. The RenderBeginHyperlink method adds an attribute named src to a hyperlink, which contains a reference to the current page. All hyperlinks rendered in pages to which CustomPageAdapter is attached will have the src attribute.

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

// A derived PageAdapter class. 
public class CustomPageAdapter : PageAdapter
{
    // Override RenderBeginHyperlink to add an attribute that  
    // references the referring page. 
    public override void RenderBeginHyperlink(
        HtmlTextWriter writer, string targetUrl,
        bool encodeUrl, string softkeyLabel, 
        string accessKey )
    {
        string url = null;

        // Add the src attribute, if referring page URL is available. 
        if( Page != null && Page.Request != null &&
            Page.Request.Url != null )
        {
            url = Page.Request.Url.AbsoluteUri;
            if( encodeUrl )
                url = HttpUtility.HtmlAttributeEncode( url );
            writer.AddAttribute( "src", url );
        }

        // Add the accessKey attribute, if caller requested. 
        if( accessKey != null && accessKey.Length == 1 )
            writer.AddAttribute( "accessKey", accessKey );

        // Add the href attribute, encode the URL if requested. 
        if( encodeUrl )
            url = HttpUtility.HtmlAttributeEncode( targetUrl );
        else
            url = targetUrl;
        writer.AddAttribute( "href", url );

        // Render the hyperlink opening tag with the added attributes.
        writer.RenderBeginTag( "a" );
    }
}

.NET Framework

Supported in: 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft