Bryan Phillips and Jason Graham
Composable Systems, LLC
http://bphillips76.spaces.live.com http://jasonAgraham.spaces.live.com
Sites
Contain all your content.
Lists
Store table-like data.
Document Libraries
Store documents.
SharePoint Designer
The tool to use for advanced customization. Meant for power users,
but EVERY developer needs to know how to use it.
Combination of files stored on the web server's
file system and files stored in the SharePoint
content database.
Setup Lists
Pages Document Library
Versioning
Approval
Pages Document Library
Versioning – Like source control. Keeps configurable
number of versions.
Approval – Prevents documents from being viewed
before someone can review and approve them. This
includes ASPX pages too.
Watch out for this GOTCHA:
Using SPD, create custom pages in the List folder that
you are working with, then move them into the Pages
doc lib
We have found that the FormView (discussed later) will
only generate controls for the doc lib and not the list you
are binding to
How to Create a Page
In SPD, right click on List folder and go to New > ASPX
Add @ Registers:
Combination of Controls
ASP.Net Controls
SharePoint Controls
Usually CRUD, but doesn't have to be
What makes a custom SharePoint page work?
There are many options, but here is what we do:
SharePoint:SPDataSource
To bind the Form to Lists
asp:FormView
To display Data and create Controls on the form
One Gotcha for custom SharePoint Pages:
You may see an error that says, "The security validation for
this page is invalid" on pages not using default.master IF
Web Page Security is turned ON
To fix this, add a
after the form tag
Gives functionality for Adding,
Updating, Deleting, and Reading
SharePoint List Items
Can be added from the "Data Source
Library" Pane
Important Attributes:
DataSourceMode
First, use "ListItem" to generate the fields.
Finally, use "List" to avoid errors.
SelectCommand
Can enter CAML with "CDATA" tags or
HTML encoded text
U2U CAML Builder – For your own sanity's
sake, do NOT create CAML without it.
Parameters
Select, Insert, Update, Delete
All have tags in them
Important Attributes
Name = "ListName"
DefaultValue = "The Actual List Name"
]]>' id="jobDescriptionsSPDatasource">
Generates ASP.Net controls for each of the fields in your
list.
Delete the ones you don't need
Automatically sets up bindings to list fields
Controls can be moved around as necessary *within*
their parent Template tag.
Important Attributes
DataSourceID = The ID of the SPDataSource
DefaultMode = Edit, Insert, or ReadOnly
Automatically generates three templates:
InsertItemTemplate (Insert)
EditItemTemplate (Edit)
ItemTemplate (ReadOnly)
Generates asp:TextBox for every field (except in ReadOnly
mode)—change the type of control as needed
YOUR CONTROLS GO HERE, INCLUDING SAVE BUTTONS
Create ASP.Net Page
asp:Button – At least one needed to save the
user's data.
asp:DropDownList, asp:ListBox etc…
SharePoint:FormField – Use to display
SharePoint control templates (e.g. PeoplePicker).
Validation Controls – Validate your user data or
SharePoint WILL throw an exception.
Important Attributes:
CommandName = Insert, Update, or Delete
CausesValidation = true or false
Redirecting the browser
You have to redirect the browser yourself or your form
will simply reload after updating the list
At least Two ways:
JavaScript
Use "Source" Query String variable, if you will always
control access to the URL of the page
Can be populated from another list to act as a
"lookup"
Important Attributes
DataSourceID = The SPDataSource used to populate
the DropDownList/ListBox
DataTextField = The field to pull the text from
DataValueField = The field to pull the value from (ID)
SelectedValue=''
The SPDataSource that the FormField is bound
to controls the List that will receive the info
Generates difficult SharePoint controls for you
People Pickers
Rich Text Controls
Important Attributes:
FieldName = Which field to generate a control for
ControlMode = Options are New, Edit, and Display
ListId = GUID for the list that the field is located in
Value=''
CSS Styles
May not appear as expected
Tools to find CSS Styles:
IE Developer Toolbar – (Built into IE 8)
Firebug – (Plug-in for FireFox, Lite version for IE, Opera)
Generate multiple HTML Controls
View HTML to get true control names for validation
and JavaScript manipulation
' />
Asp:RequiredFieldValidator
Asp:ValidationSummary
The "ValidationGroup" attribute
Marks a control for validation
One for each control to validate
Important Attributes:
ControlToValidate = Name of Control
ErrorMessage = Message displayed in
ValidationSummary
Text = Message to be displayed where
RequiredFieldValidator exists
ValidationGroup = Name of Validation Group
Displays validation info to user (error messages)
One for each ValidationGroup
Important Attributes:
HeaderText = Text to be displayed above error messages
DisplayMode = BulletList (Default), List,
SingleParagraph
EnableClientScript
True—renders client side script to update this control
False—allows it to only update on a round trip to the server
ValidationGroup = The name of the ValidationGroup
FINALLY: On the button that you are using to
Insert or Edit with: Include an attribute for
ValidationGroup="MyGroup"
Adding Validation
DEMO if time permits
Could be a talk all on its own
Utilize the "IF" conditional branches to avoid
infinite loops
Bryan Phillips
http://bphillips76.spaces.live.com
Jason Graham
http://jasonAgraham.spaces.live.com
Composable Systems, LLC
www.ComposableSystems.net