Adapter Interaction with ASP.NET

ASP.NET mobile device adapters for a specified mobile device can interact with other adapters, controls, and pages through the following properties:

  • A control adapter can access its associated control through the Control property, defined in the ControlAdapter base class.

    Note   Each control adapter class must define a new, strongly typed Control property. For example, an adapter for the Label control would include the following code.

    [C#]

    protected new Label Control
    {
        get
        {
            return (Label)base.Control;
        }
    }
    
  • A control adapter can access its associated page through the Page property, defined in the ControlAdapter base class.

    Note   A page adapter class must implement a read/write Page property. This is an implementation requirement of the IPageAdapter interface. The following is an example of such code.

    [C#]

    private MobilePage _page;
    public override MobilePage Page
    {
        get
        {
            return _page;
        }
        set
        {
             _page = value;
        }
    }
    
  • A control adapter can access the current device capabilities through the Device property, defined in the ControlAdapter base class. This property is a short form for the following expression.

    [C#]

    (MobileDeviceCapabilities)Page.Request.Browser
    
  • For convenience, the device-specific control adapter base class should expose properties that allow access of the page adapter and the form adapter. The following is an example of such code.

    [C#]

    protected WmlPageAdapter PageAdapter
    {
        get
        {
            return ((WmlPageAdapter)Page.Adapter);
        }
    }
    
    protected WmlFormAdapter FormAdapter
    {
        get
        {
            return ((WmlFormAdapter)FormAdapter);
        }
    }
    

See Also

Adding New Device Adapters and Device Support