Today we will see how we can create custom mobile view in
share point 2010.
Ok when we create a
site , by default , when opened in browser it shows something like bellow
Which does not look good enough . it only shows lists and
libraries. Suppose I want to customize the look and feel completely then why not to deploy some pages in the
layout directory for our use in Mobile site.
Ok , I am telling just concepts here map layout folder in visual studio. Create
a directory for your projects for
example
Layouts/your project/
Here we will place all stuffs like css etc.
In the same folder we can create a master page and some
pages to so the data . master page will determine the mobile page look and
feel.
Now the work remains to stop the default mobile redirection
and redirect to our own pages. Ok
Just add a line in web.config of content site before</system.web>
<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<filter>isMobileDevice=false</filter>
</browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<filter>isMobileDevice=false</filter>
</browserCaps>
Now add a webpart on to home page of site
. check the user agent and redirect to mobile view . as bellow.
string userAgent = HttpContext.Current.Request.UserAgent;
if (userAgent.Contains("BlackBerry")
|| (userAgent.Contains("iPhone")
|| (userAgent.Contains("Android"))))
{
HttpContext.Current.Response.Redirect("_layouts/<your project>/index.aspx");
Control control =
Page.LoadControl(_ascxPath);
Controls.Add(control);
}
There are other ways also to customize
mobile view . and I will discuss it in upcoming posts.
No comments:
Post a Comment