| 佔位符 | 來源與取值 |
| ListTypeID | 列表範本 ID(如 104)或 SPListTemplateType 列舉值(如 Announcements、Contacts)。
• 站台定義中列表:Onet.xml List@Type
• UI 建立列表:以建立時選擇的列表範本 ID 為準 |
| FieldType | SPFieldType 列舉值(Text、Number、DateTime...)或 fldtypes*.xml 中 <Field Name="TypeName"> 定義的自訂欄位類型名稱。 |
| Field | 欄位**內部名稱**(非顯示名稱)。
• Schema.xml 定義:Field@Name
• UI 建立欄位:SPField.InternalName(由顯示名稱自動編碼,含空格/標點時無法對應,故無法定制)。 |
重要:若欄位顯示名稱含空格/標點,系統產生的內部名稱將包含編碼字元(如 _x0020_),導致 ID 無法匹配,**此類欄位無法透過此機制定制渲染**。
內建 RenderingTemplate 清單
WSS 安裝後預載於 MobileDefaultTemplates.ascx:
MobileCustomListField_Contacts_Text_WorkPhone
MobileCustomListField_Contacts_Text_HomePhone
MobileCustomListField_Contacts_Text_CellPhone
MobileCustomListField_Contacts_Text_Email
MobileCustomListField_PictureLibrary_Computed_ImageSize
MobileCustomListField_Posts_DateTime_PublishedDate
勿修改 MobileDefaultTemplates.ascx。可建立同 ID 新模板覆寫,但有風險:可能破壞相依原模板的其他方案。載入順序:內建 → 自訂(字母序後者勝出),同檔案重複 ID 皆不載入。
定制步驟標準化流程
- 建立
.ascx 使用者控制項檔,置於 \12\TEMPLATE\CONTROLTEMPLATES。
- 加入頁面指示詞註冊必要命名空間(
mobile、SharePoint、SPMobile)。
- 宣告
<SharePoint:RenderingTemplate>,ID 依命名規則設定。
<Template> 內直接放置可渲染控制項(如 <mobile:Label>),或參考繼承 SPMobileBaseFieldControl 的自訂控制項標籤。
- 儲存檔案,執行
iisreset 生效。
範例:公告列表 Title 欄位自訂渲染
<SharePoint:RenderingTemplate RunAt="Server" ID="MobileCustomListField_Announcements_Text_Title">
<Template>
<mobile:Label Text="Title field in Announcements List" RunAt="Server" />
</Template>
</SharePoint:RenderingTemplate>
進階:巢狀 RenderingTemplate
可在 <Template> 內參考其他 RenderingTemplate(透過 SPMobileComponent):
<SharePoint:RenderingTemplate ID="Mobile_104_View_Navigation" RunAt="Server">
<Template>
<mobile:Link Text="ASP.NET Website" NavigateUrl="https://www.asp.net" RunAt="Server" />
<mobile:Label RunAt="Server" Text="" BreakAfter="True" />
<SPMobile:SPMobileComponent RunAt="Server" TemplateName="Mobile_Default_View_Navigation" />
</Template>
</SharePoint:RenderingTemplate>
此技巧可組合預設渲染與自訂內容,保留原有導航列同時加入新連結。
- 上一篇文章: WSS 3.0 SDK 實戰演練:在 Mobile 顯示表單定制列表項標題——以 RenderingTemplate 覆寫預設渲染
- 下一篇文章: WSS 3.0 SDK 實戰演練:定制 Mobile 列表視圖頁內容區——以 RenderingTemplate 注入問候訊息
Copyright ©
程式碼之家 All Rights Reserved