Compartir a través de


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.

    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.

    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 of the following expression.

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

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

See Also

Other Resources

Adding New Device Adapters and Device Support