Date post: | 30-Mar-2015 |
Category: |
Documents |
Upload: | jesus-stalker |
View: | 213 times |
Download: | 0 times |
Advanced List Form Customization in WSS 3.0Arthur BrostPortals and Collaboration Practice Managertwentysix New York
IBP402
About Me
Arthur BrostPortals and Collaboration Practice Manager for twentysix New York
twentysix New YorkGold Managed PartnerPractices in Enterprise Integration, Business Intelligence and Portals and Collaboration
Customizing List Item FormsSharePoint DesignerCustom ASPX pageSchema.xmlControl Templates
HTMLASP.NET Server ControlsSilverlight Controls
List Field IteratorCustom Field Types
AJAX Toolkit Controls
Session Summary
SharePoint List Forms
Used to display individual itemsNew, Display and Edit formsAuto-generated based on list schemaUses ListForm control template to layout the form.
List Item FormCustomization Options
SharePoint DesignerCustom ASPX pageModify Schema.Xml Form elementsControl Templates
List Item Form CustomizationSharePoint Designer
Applies to single list instanceListForm Web PartCustom List Form control
New fields not automatically added
Using SharePoint Designer
List Item Form CustomizationCustom ASPX page
Specified in List Feature or SchemaSame form as SharePoint DesignerBy Default no code allowedAdding Web Parts is possible but not recommended / supported
Specifying a Custom FormIn a Feature<ListTemplate
Name="MyTemplate" Type="2100"
…NewPage="MyCreateList.aspx"
EditPage="MyEditList.aspx“…
>
Specifying a Custom FormIn a List Definition<List Title="MyList"...> <MetaData>
… <Forms> <Form Type="DisplayForm“ SetupPath="pages\form.aspx“ Url="Forms/DispForm.aspx“ /> ...
List Item Form CustomizationSchema.XML
Supported in WSS 2.0Code form elements in CAMLStill supported in WSS 3.0 by using the UseLegacyForm attribute
Schemal.Xml code
<Forms><Form Type="EditForm" Url="editform.htm">
<ListFormOpening>…</ListFormOpening><ListFormButtons>…</ListFormButtons><ListFormBody>…</ListFormBody>
List Item Form CustomizationASP.NET Control Templates
Combination of HTML and Child ControlsUsed by the ListForm Web PartRegistered by list type or content typeStored in …\12\TEMPLATE\CONTROLTEMPLATESMay override default templates
Example Control HierarchyDocumentLibraryForm
DocumentLibraryFormCore
DocumentLibraryFields
CompositeField
NumberField
Control Template..\12\Template\ControlTemplates\DefaultTemplates
<SharePoint:RenderingTemplate ID="ListForm" …><Template>
<SPAN id='part1'><SharePoint:InformationBar runat="server"/><wssuc:ToolBar …><Template_RightButtons>
<SharePoint:NextPageButton runat="server"/><SharePoint:SaveButton runat="server"/><SharePoint:GoBackButton runat="server"/>
</Template_RightButtons></wssuc:ToolBar><SharePoint:FormToolBar runat="server"/><TABLE …>
<SharePoint:ChangeContentType runat="server"/><SharePoint:FolderFormFields runat="server"/><SharePoint:ListFieldIterator runat="server"/>…
Custom Template..\12\Template\ControlTemplates\MyTemplate.ASCX
…<%@ Register
TagPrefix="MyControls" Assembly="MyControls, …” Namespace="MyControls" %>
…<SharePoint:RenderingTemplate ID="MyListForm" …>
<Template>…<MyControls:ItemChildren runat="server" />…
</Template></SharePoint:RenderingTemplate>…
By List Defintion..\12\Features\MyList\My\Schema.xml
<List Name=“MyList“ …><MetaData>
…<Forms>
…<Form Type="NewForm" Template="MyListForm"…>
</Forms></MetaData>
</List>
By Content Type..\12\Template\Features\MyType\Elements.xml
<ContentType ID="0x0126" Name="MyType" …>…
<XmlDocuments><XmlDocument …>
<FormTemplates …><Display>MyListForm</Display><Edit>ListForm</Edit><New>ListForm</New>
</FormTemplates></XmlDocument>
</XmlDocuments></ContentType>
Setting/Checking the Template from Code
//List…SPList list = web.Lists["MyList"];String NewFormTemplate =
list.Forms[PAGETYPE.PAGE_NEWFORM].TemplateName;//Content TypeSPContentType type = list.ContentTypes[0];String NewFormTemplate = type.NewFormTemplateName;type.NewFormTemplateName = "MyListForm";type.Update();…
Demo Scenario
Two lists: Photos, and RatingsMultiple ratings per photoRatings contains a lookup to Photos
Custom Item Template
Customized List Item Form template
demo
ASP.Net Web Controls
Custom ASP.Net WebControl on a List Item form
demo
List Field Iterator
Iterates fieldsUsed in various control templatesOverride IsFieldExcluded for field level security
Custom List Field Iterator
Suppress fields based on user
demo
Custom Field Types
Field Type DefinitionRender Pattern (CAML)
Field ClassDerived from SPFieldAllows Custom Validation
Field ControlDerived from BaseFieldControlSpecifies Field Template
Field Template
<SharePoint:RenderingTemplate ID="CustomFieldTemplate" ...> <Template> <asp:TextBox ID="TextField" ...> Custom </Template></SharePoint:RenderingTemplate>
Field Control Class
[Guid("42FD6883-EA0D-43fb-9201-1443A348334B")]public class MyFieldControl : Microsoft.SharePoint.WebControls.NumberField{… protected override string DefaultTemplateName { get { return "CustomFieldTemplate"; } }}
Field Class
[Guid("2e0a281b-ef91-46ab-86f3-f6aadaa4da0e")]public class MyField : SPFieldNumber{ public MyField(SPFieldCollection fields, string fieldName) : base(fields, fieldName)… public override BaseFieldControl FieldRenderingControl { … get { BaseFieldControl fieldControl = new MyFieldControl(); fieldControl.FieldName = this.InternalName; return fieldControl; } }}
FLDTYPES_*.Xml..\12\Template\XML
<FieldTypes> <FieldType> <Field Name="TypeName">CustomType</Field> <Field Name="ParentType">Number</Field> <Field Name="TypeDisplayName">Custom Type</Field> <Field Name="TypeShortDescription>Sample Custom Field Type</Field> <Field Name="UserCreatable">TRUE</Field> <Field Name="ShowInListCreate">TRUE</Field> <Field Name="ShowInSurveyCreate">TRUE</Field> <Field Name="ShowInDocumentLibraryCreate">TRUE</Field> <Field Name="ShowInColumnTemplateCreate">TRUE</Field> <Field Name="FieldTypeClass">MyNameSpace.MyField, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b3e674199e6c34cb</Field> <RenderPattern Name="DisplayPattern"> …
AJAX Field Controls
Custom Field Type Template Using AJAX
demo
Silverlight Controls
Silverlight Controls on a List Item Form
demo
Useful Links
Creating Custom Form TemplatesHow to: Create a Custom Control for a FormHow to: Create a Custom Field Type and Field ControlWalkthrough: Creating a Custom Field Type
Post Event DVD brought to you courtesy of:
SUBMIT AN EVALUATION
For a chance to win an 8GB ZUNE!Submit evaluations on
MySPC www.MicrosoftSharePointConferenc
e.com
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.