PageAdapter Class

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)

System.Object
  System.Web.UI.Adapters.ControlAdapter
    System.Web.UI.Adapters.PageAdapter

public abstract class PageAdapter : ControlAdapter

NameDescription
System_CAPS_protmethodPageAdapter()

This API supports the product infrastructure and is not intended to be used directly from your code. Initializes a new instance of the PageAdapter class.

NameDescription
System_CAPS_protpropertyBrowser

Gets a reference to the browser capabilities of the client making the current HTTP request.(Inherited from ControlAdapter.)

System_CAPS_pubpropertyCacheVaryByHeaders

Gets a list of additional HTTP headers by which caching is varied for the Web page to which this derived page adapter is attached.

System_CAPS_pubpropertyCacheVaryByParams

Gets 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.

System_CAPS_protpropertyClientState

Gets an encoded string that contains the view and control states data of the Web page to which this derived page adapter is attached.

System_CAPS_protpropertyControl

Gets a reference to the control to which this control adapter is attached.(Inherited from ControlAdapter.)

System_CAPS_protpropertyPage

Gets a reference to the page where the control associated with this adapter resides.(Inherited from ControlAdapter.)

System_CAPS_protpropertyPageAdapter

Gets a reference to the page adapter for the page where the associated control resides.(Inherited from ControlAdapter.)

NameDescription
System_CAPS_protmethodBeginRender(HtmlTextWriter)

Called 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.)

System_CAPS_protmethodCreateChildControls()

Creates the target-specific child controls for a composite control.(Inherited from ControlAdapter.)

System_CAPS_pubmethodDeterminePostBackMode()

Determines whether the Web page is in postback and returns a name/value collection of the postback variables.

System_CAPS_pubmethodDeterminePostBackModeUnvalidated()

System_CAPS_protmethodEndRender(HtmlTextWriter)

Called 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.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_protmethodGetPostBackFormReference(String)

Returns a DHTML code fragment that the client browser can use to reference the form on the page that was posted.

System_CAPS_pubmethodGetRadioButtonsByGroup(String)

Retrieves a collection of radio button controls specified by groupName.

System_CAPS_pubmethodGetStatePersister()

Returns an object that is used by the Web page to maintain the control and view states.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodLoadAdapterControlState(Object)

Loads 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.)

System_CAPS_protmethodLoadAdapterViewState(Object)

Loads 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.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnInit(EventArgs)

Overrides the OnInit method for the associated control.(Inherited from ControlAdapter.)

System_CAPS_protmethodOnLoad(EventArgs)

Overrides the OnLoad method for the associated control.(Inherited from ControlAdapter.)

System_CAPS_protmethodOnPreRender(EventArgs)

Overrides the OnPreRender method for the associated control.(Inherited from ControlAdapter.)

System_CAPS_protmethodOnUnload(EventArgs)

Overrides the OnUnload method for the associated control.(Inherited from ControlAdapter.)

System_CAPS_pubmethodRegisterRadioButton(RadioButton)

Adds a radio button control to the collection for a specified radio button group.

System_CAPS_protmethodRender(HtmlTextWriter)

Generates the target-specific markup for the control to which the control adapter is attached.(Inherited from ControlAdapter.)

System_CAPS_pubmethodRenderBeginHyperlink(HtmlTextWriter, String, Boolean, String)

Renders an opening hyperlink tag that includes the target URL to the response stream.

System_CAPS_pubmethodRenderBeginHyperlink(HtmlTextWriter, String, Boolean, String, String)

Renders an opening hyperlink tag that includes the target URL and an access key to the response stream.

System_CAPS_protmethodRenderChildren(HtmlTextWriter)

Generates the target-specific markup for the child controls in a composite control to which the control adapter is attached.(Inherited from ControlAdapter.)

System_CAPS_pubmethodRenderEndHyperlink(HtmlTextWriter)

Renders a closing hyperlink tag to the response stream.

System_CAPS_pubmethodRenderPostBackEvent(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.

System_CAPS_pubmethodRenderPostBackEvent(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.

System_CAPS_protmethodRenderPostBackEvent(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.

System_CAPS_protmethodSaveAdapterControlState()

Saves control state information for the control adapter.(Inherited from ControlAdapter.)

System_CAPS_protmethodSaveAdapterViewState()

Saves view state information for the control adapter.(Inherited from ControlAdapter.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodTransformText(String)

Transforms text for the target browser.

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
Available since 2.0

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

Return to top
Show:
© 2016 Microsoft