ASP.NET vs. SharePoint: Mobile Adapter Development
Applies to: SharePoint Foundation 2010
This topic describes the differences between development of mobile control adapters in Microsoft ASP.NET 3.5 and mobile Web Part adapters in Microsoft SharePoint Foundation.
Programming the SharePoint Foundation Mobile Adaption Framework
The SharePoint Foundation framework for mobile adapters is actually simpler to develop against than the Microsoft ASP.NET 3.5 mobile adaption system. In SharePoint Foundation, as with the Microsoft ASP.NET 3.5 system, you can create a mobile adapter control for every Web Part that you want to be accessible to mobile devices. You map that adapter to the Web Part whose rendering it adapts in the compat.browser file.
However, there are some ways in which developing with the SharePoint Foundation framework differs from mobile adapter development with Microsoft ASP.NET 3.5. For the most part these differences are needed in order to conform to the security model of SharePoint Foundation:
The mobile adapter framework in SharePoint Foundation is intended to be used for adapting only Web Parts, not other kinds of controls. If you need to use other kinds of controls on a mobile page, see the controls in the namespace Microsoft.SharePoint.MobileControls, rather than adapting a control from Microsoft.SharePoint.WebControls.
Your adapter class derives from the Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter class instead of directly from the System.Web.UI.Adapters.ControlAdapter class.
Your adapter class must be registered as a Safe Control. For more information about how to do this, see Working with Web.config Files.
You do not override the Render(HtmlTextWriter) method that is inherited from the ControlAdapter class. Instead, you override one or both of these methods: CreateControlsForSummaryView() and CreateControlsForDetailView().
You do not override the OnLoad(EventArgs), OnInit(EventArgs), OnPreRender(EventArgs), and OnUnload(EventArgs) methods that WebPartMobileAdapter inherits from ControlAdapter. Instead, if you need additional logic for any of these events, you override one or more of the specific SharePoint-secure replacement methods of WebPartMobileAdapter: OnLoadForMobile(EventArgs), OnInitForMobile(EventArgs), OnPreRenderForMobile(EventArgs), and OnUnloadForMobile(EventArgs).
Important
See the reference topics for these four methods for important notes about how to override these methods.
The mobile-accessible Web Parts pages are objects of the class WebPartMobilePage, but you do not create them directly. When a mobile device user navigates to a Web Parts page that contains Web Parts that have been adapted for mobile devices, a WebPartMobilePage object is created by the runtime and returned to the mobile device.
Each Web Parts page that contains Web Parts that have been adapted for mobile devices has a corresponding application page where users can set the visibility and order of the adapted Web Parts. These pages are objects of a hidden type, so you cannot programmatically affect these properties.