arthur brost portals and collaboration practice manager twentysix new york i bp402

37

Upload: jesus-stalker

Post on 30-Mar-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402
Page 2: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Advanced List Form Customization in WSS 3.0Arthur BrostPortals and Collaboration Practice Managertwentysix New York

IBP402

Page 3: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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

Page 4: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Customizing List Item FormsSharePoint DesignerCustom ASPX pageSchema.xmlControl Templates

HTMLASP.NET Server ControlsSilverlight Controls

List Field IteratorCustom Field Types

AJAX Toolkit Controls

Session Summary

Page 5: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

SharePoint List Forms

Used to display individual itemsNew, Display and Edit formsAuto-generated based on list schemaUses ListForm control template to layout the form.

Page 6: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

List Item FormCustomization Options

SharePoint DesignerCustom ASPX pageModify Schema.Xml Form elementsControl Templates

Page 7: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

List Item Form CustomizationSharePoint Designer

Applies to single list instanceListForm Web PartCustom List Form control

New fields not automatically added

Page 8: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Using SharePoint Designer

Page 9: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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

Page 10: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Specifying a Custom FormIn a Feature<ListTemplate

Name="MyTemplate" Type="2100"

…NewPage="MyCreateList.aspx"

EditPage="MyEditList.aspx“…

>

Page 11: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Specifying a Custom FormIn a List Definition<List Title="MyList"...> <MetaData>

… <Forms> <Form Type="DisplayForm“ SetupPath="pages\form.aspx“ Url="Forms/DispForm.aspx“ /> ...

Page 12: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

List Item Form CustomizationSchema.XML

Supported in WSS 2.0Code form elements in CAMLStill supported in WSS 3.0 by using the UseLegacyForm attribute

Page 13: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Schemal.Xml code

<Forms><Form Type="EditForm" Url="editform.htm">

<ListFormOpening>…</ListFormOpening><ListFormButtons>…</ListFormButtons><ListFormBody>…</ListFormBody>

Page 14: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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

Page 15: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Example Control HierarchyDocumentLibraryForm

DocumentLibraryFormCore

DocumentLibraryFields

CompositeField

NumberField

Page 16: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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"/>…

Page 17: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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>…

Page 18: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

By List Defintion..\12\Features\MyList\My\Schema.xml

<List Name=“MyList“ …><MetaData>

…<Forms>

…<Form Type="NewForm" Template="MyListForm"…>

</Forms></MetaData>

</List>

Page 19: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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>

Page 20: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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();…

Page 21: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Demo Scenario

Two lists: Photos, and RatingsMultiple ratings per photoRatings contains a lookup to Photos

Page 22: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Custom Item Template

Customized List Item Form template

demo

Page 23: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

ASP.Net Web Controls

Custom ASP.Net WebControl on a List Item form

demo

Page 24: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

List Field Iterator

Iterates fieldsUsed in various control templatesOverride IsFieldExcluded for field level security

Page 25: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Custom List Field Iterator

Suppress fields based on user

demo

Page 26: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Custom Field Types

Field Type DefinitionRender Pattern (CAML)

Field ClassDerived from SPFieldAllows Custom Validation

Field ControlDerived from BaseFieldControlSpecifies Field Template

Page 27: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Field Template

<SharePoint:RenderingTemplate ID="CustomFieldTemplate" ...> <Template> <asp:TextBox ID="TextField" ...> Custom </Template></SharePoint:RenderingTemplate>

Page 28: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Field Control Class

[Guid("42FD6883-EA0D-43fb-9201-1443A348334B")]public class MyFieldControl : Microsoft.SharePoint.WebControls.NumberField{… protected override string DefaultTemplateName { get { return "CustomFieldTemplate"; } }}

Page 29: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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; } }}

Page 30: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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"> …

Page 31: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

AJAX Field Controls

Custom Field Type Template Using AJAX

demo

Page 32: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Silverlight Controls

Silverlight Controls on a List Item Form

demo

Page 33: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

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

Page 35: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

Post Event DVD brought to you courtesy of:

Page 36: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

SUBMIT AN EVALUATION

For a chance to win an 8GB ZUNE!Submit evaluations on

MySPC www.MicrosoftSharePointConferenc

e.com

Page 37: Arthur Brost Portals and Collaboration Practice Manager twentysix New York I BP402

© 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.