SharePoint Mobile Development Help
So today I came across a terrific question.
“I’ve reviewed MSDN’s documentation:
However it still leaves me at a bit of a loss on the best strategy for rendering custom web parts for mobile browsers.
Has anyone had any experience in creating custom web parts that will detect a mobile browser and render accordingly?
Here are my questions:
1. What is the best way to detect that the web part is being viewed by a mobile browser. Is this a good approach?
2. Is it better to create a “mobile skin”, and have that skin as a configurable option, then configure the web part accordingly on the mobile page layout? I was thinking this might be better as it would leverage SharePoint’s browser detection as found in compat.browser .”
This is a good question.
Mobile pages are pages that are designed for Mobile browsing. If you open that page in your browser, it will render exactly the same as it would in the phone. This is necessary to improve usability and compatibility with all of the phone operating systems/browsers out there. (Plus it makes testing easier, don’t forget to have an emulator in your testing environment though as there are subtle differences in how phone browsers may render content.)
The secret to a good mobile page/part/anything is understanding Microsoft’s recommendations and use of their normal mobile pages. When you go to the http://portal/_layouts/mobile page you are visiting the mobile pages of SharePoint. This allows you to modify lists, and libraries, but has limitations related to how mobile devices render certain objects and the fact you don’t want to overload a mobile device with useless data.
Take a look at the mobile pages of SharePoint. These are found within the 12 hive, and you can examine how they build/render mobile content. “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\MOBILE” Notice they do not use webparts. A webpart in itself really just renders HTML and processes server side code. Instead they use controls which you can also use.
If you think about it the pages you develop that house controls should be stored with the other Mobile pages of SharePoint. SharePoint does all the mobile checking for you, and your developed material sits/works in the same place. So instead of trying to check if the user is using a mobile device, you can assume if they are viewing the mobile pages that they are, and if they are using the non mobile pages they are not.
My advice would be to read all of the articles/sections here: http://msdn.microsoft.com/en-us/library/ms464268.aspx (especially the fields part) and take a good look at those files in the Hive Directory, and then finally look over the Microsoft.SharePoint.MobileControls namespace: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.mobilecontrols.aspx these controls can really help, and if you can use them, do so, don’t reinvent or re-create everything if you don’t need to.
By looking these over you should be able to figure out how to best develop for mobile using SharePoint (the key to using SharePoint is building/using what they have already done, don’t do it all on your own, it will take much longer and be more prone to customization issues.)
Hope this helps,
P.S – Wondering what mobile devices are supported and have been tested? Find that out here: http://support.microsoft.com/kb/930147