SPMobileWebContents Class

Specifies the ID of the <RenderingTemplate> that is used when rendering the main contents area of a mobile home page.

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    System.Web.UI.MobileControls.MobileControl
      Microsoft.SharePoint.MobileControls.SPMobileComponent
        Microsoft.SharePoint.MobileControls.SPMobileTemplateSelector
          Microsoft.SharePoint.MobileControls.SPMobileWebTemplateSelector
            Microsoft.SharePoint.MobileControls.SPMobileWebContents

Namespace:  Microsoft.SharePoint.MobileControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class SPMobileWebContents _
    Inherits SPMobileWebTemplateSelector
'Usage
Dim instance As SPMobileWebContents
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SPMobileWebContents : SPMobileWebTemplateSelector

Remarks

For an overview of the role of this class in the page rendering system for mobile devices, see Mobile Page Rendering System.

Do not call SPMobileWebContents in your code. It is documented to provide further understanding of how mobile Web pages are rendered and how the rendering can be customized.

For information on the rendering of the main contents area of pages other than the home page, see SPMobileListContents.

The <RenderingTemplate> ID takes the following form.

IntendedPageUse_WebSiteType_PageType_Contents

The placeholders IntendedPageUse and WebSiteType are defined as in Mobile Page Rendering System,

The PageType is the type of page, such as HomePage or NewForm. For all practical purposes, in SharePoint Foundation, this part of the ID is always HomePage.

The "Contents" indicates that <RenderingTemplate> applies to the main contents part of the page.

The following excerpts from the MobileDefaultTemplates.ascx file (in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\CONTROLTEMPLATES) shows how the SPMobileWebContents is called by the “MobileHomePageContents” rendering template.

<SharePoint:RenderingTemplate RunAt="Server" ID="MobileHomePageContents">
  <Template>
    <SPMobile:SPMobileWebContents RunAt="Server" />
  </Template>
</SharePoint:RenderingTemplate>

The following excerpt from the same file shows some of the built-in rendering templates that might be called, in turn, by the SPMobileWebContents object:

<SharePoint:RenderingTemplate RunAt="Server" id="Mobile_Default_HomePage_Contents">
 <Template>
    <SPMobile:SPMobileComponent RunAt="Server" 
       TemplateName="Mobile_STS_HomePage_Contents" 
  </Template>
</SharePoint:RenderingTemplate>
<SharePoint:RenderingTemplate RunAt="Server" ID="Mobile_STS_HomePage_Contents">
  <Template>
    <SPMobile:SPMobileParentWebControls RunAt="Server" />
    <SPMobile:SPMobileGenericListIterator RunAt="Server" />
    <SPMobile:SPMobileLabel RunAt="Server" 
       Text="<%$Resources:wss, mobile_listcategory_workspaces_text%>" 
       BreakAfter="true" />
    <SPMobile:SPMobileSubWebControls RunAt="Server" />
  </Template>
</SharePoint:RenderingTemplate>

If a template with the matching name cannot be found for a specific IntendedPageUse and WebSiteType the IntendedPageUse_Default_HomePage_Contents <RenderingTemplate> is used. For example, in the context of a BLOG site the SPMobileWebContents object defines a template named Mobile_BLOG_HomePage_Contents. Because there is no <RenderingTemplate> with that name, the Mobile_Default_HomePage_Contents <RenderingTemplate> is used.

Do not change MobileDefaultTemplates.ascx or GbwMobileDefaultTemplates.ascx. For any Web site type, such as BLOG, that does not already have a <RenderingTemplate> defined in MobileDefaultTemplates.ascx or GbwMobileDefaultTemplates.ascx, you can override the Mobile_Default_HomePage_Contents <RenderingTemplate> with the following method.

Create a custom *.ascx file in the ...\CONTROLTEMPLATES folder that contains a <RenderingTemplate> with the name IntendedPageUse_WebSiteType_HomePage_Contents. Specify the name of a <Template Element (Site)>, such as BLOG, (or the ID of a <Template Element (Site)> for a custom site definition) in place of WebSiteType. Your custom <RenderingTemplate> then calls a combination of controls different from those used by IntendedPageUse_Default_HomePage_Contents to render the contents. (Otherwise the customization would be pointless.)

The runtime automatically gives preference to your custom <RenderingTemplate> over the IntendedPageUse_Default_HomePage_Contents <RenderingTemplate> in MobileDefaultTemplates.ascx or GbwMobileDefaultTemplates.ascx.

For more about customizing Web page main contents, see Walkthrough: Customizing a Mobile Home Page.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPMobileWebContents Members

Microsoft.SharePoint.MobileControls Namespace

Other Resources

Mobile Page Rendering System

Understanding WebTemp*.xml Files

Walkthrough: Customizing a Mobile Home Page