370 likes | 690 Views
I BP402. Advanced List Form Customization in WSS 3.0. Arthur Brost Portals and Collaboration Practice Manager twentysix New York. About Me. Arthur Brost Portals and Collaboration Practice Manager for twentysix New York twentysix New York Gold Managed Partner
E N D
IBP402 Advanced List Form Customization in WSS 3.0 Arthur Brost Portals and Collaboration Practice Manager twentysix New York
About Me • Arthur Brost • Portals and Collaboration Practice Manager for twentysix New York • twentysix New York • Gold Managed Partner • Practices in Enterprise Integration, Business Intelligence and Portals and Collaboration
Session Summary • Customizing List Item Forms • SharePoint Designer • Custom ASPX page • Schema.xml • Control Templates • HTML • ASP.NET Server Controls • Silverlight Controls • List Field Iterator • Custom Field Types • AJAX Toolkit Controls
SharePoint List Forms • Used to display individual items • New, Display and Edit forms • Auto-generated based on list schema • Uses ListForm control template to layout the form.
List Item FormCustomization Options • SharePoint Designer • Custom ASPX page • Modify Schema.Xml Form elements • Control Templates
List Item Form CustomizationSharePoint Designer • Applies to single list instance • ListForm Web Part • Custom List Form control • New fields not automatically added
List Item Form CustomizationCustom ASPX page • Specified in List Feature or Schema • Same form as SharePoint Designer • By Default no code allowed • Adding 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.0 • Code form elements in CAML • Still 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 Controls • Used by the ListForm Web Part • Registered by list type or content type • Stored in …\12\TEMPLATE\CONTROLTEMPLATES • May override default templates
Control Template..\12\Template\ControlTemplates\DefaultTemplates • <SharePoint:RenderingTemplate ID="ListForm" …> • <Template> • <SPAN id='part1'> • <SharePoint:InformationBarrunat="server"/> • <wssuc:ToolBar …> • <Template_RightButtons> • <SharePoint:NextPageButtonrunat="server"/> • <SharePoint:SaveButtonrunat="server"/> • <SharePoint:GoBackButtonrunat="server"/> • </Template_RightButtons> • </wssuc:ToolBar> • <SharePoint:FormToolBarrunat="server"/> • <TABLE …> • <SharePoint:ChangeContentTyperunat="server"/> • <SharePoint:FolderFormFieldsrunat="server"/> • <SharePoint:ListFieldIteratorrunat="server"/> • …
Custom Template..\12\Template\ControlTemplates\MyTemplate.ASCX • … • <%@ Register • TagPrefix="MyControls" Assembly="MyControls, …” Namespace="MyControls" %> • … • <SharePoint:RenderingTemplate ID="MyListForm" …> • <Template> • … • <MyControls:ItemChildrenrunat="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 Type • SPContentType type = list.ContentTypes[0]; • String NewFormTemplate = type.NewFormTemplateName; • type.NewFormTemplateName = "MyListForm"; • type.Update(); • …
Demo Scenario • Two lists: Photos, and Ratings • Multiple ratings per photo • Ratings contains a lookup to Photos
Custom Item Template Customized List Item Form template demo
ASP.Net Web Controls Custom ASP.NetWebControl on a List Item form demo
List Field Iterator • Iterates fields • Used in various control templates • Override IsFieldExcluded for field level security
Custom List Field Iterator Suppress fields based on user demo
Custom Field Types • Field Type Definition • Render Pattern (CAML) • Field Class • Derived from SPField • Allows Custom Validation • Field Control • Derived from BaseFieldControl • Specifies 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 BaseFieldControlFieldRenderingControl • { • … • get • { • BaseFieldControlfieldControl = 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 Templates • How to: Create a Custom Control for a Form • How to: Create a Custom Field Type and Field Control • Walkthrough: Creating a Custom Field Type
Contact Information • Arthur Brost Arthur.Brost@26ny.com • www.26ny.com
SUBMIT AN EVALUATION For a chance to win an 8GB ZUNE! Submit evaluations on MySPC www.MicrosoftSharePointConference.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.