Web parts for SharePoint - SharePoint Bruger Gruppe

Download Report

Transcript Web parts for SharePoint - SharePoint Bruger Gruppe

Web parts for SharePoint
What’s a web part?
 Application that can be added to a page with a web part zone.
 Inhierits from web controls
 Can be developed using C# or VB
 The concept of web parts are not just for SharePoint
Web part lifecycle
Without postback
With postback
 OnInit
 OnInit
 OnLoad
 CreateChildControls
 CreateChildControls
 OnLoad
 OnPreRender
 OnPreRender
 Render
 Render
OnInit
 Used to initialize controls.
OnLoad
 Set the basic layout of the web part like
 Title
 Chrometype
 Width/height
 These can also be found in the properties of the web part and
be set individually after the web part has been deployed.
CreateChildControls
 Create child controls and layout here
OnPreRender
 Used for tasks that needs to be executed before the web part
is rendered.
 Load data
Render
 Renders the whole web part
 Only overwritten i rare situations i case of special rendering
requirements
<name>.webpart
 Description for the web part shown in the Web part Gallery
<name>.xml
 Adds the web part to a group in the Web part Gallery
 If a group is not specified, the web part is placed in the group
Miscelleaneous
Feature.xml
 Location of the <name>.xml
 Location of the <name>.webpart
Manifest.xml
 Tells where the feature.xml file is located
 Location of the assembly
Create your own properties
 Enables you to add string/integer (textboxes), bool (checkboxes),
collection (dropdownlists) to your properties.
 The web part already contains properties, so all you have to do is
add your own.
Extend your properties
 Toolparts
 Enables you to add listboxes, peoplepicker, buttons etc. to
the properties.
 Has it’s own lifecycle similar to a web part.
Time to deploy
 Two ways to deploy your wsp file:
1.
Using install.bat (created by VS for you to use)

2.
REMEMBER to change the URL in the install.bat if you want to
install it on a server with a different name.
Using stsadm


stsadm -o addsolution -filename <Solution filename>
stsadm -o activatefeature {-filename <relative path to
Feature.xml> | -name <feature folder> | -id <feature Id>} [-url
<url>] [-force]
A complete list of stsadm operations can be found here:
http://blogs.technet.com/josebda/archive/2008/03/15/complete-reference-of-all-stsadmoperations-with-parameters-in-moss-2007-sp1.aspx
My favorite sites for SharePoint:
 http://www.codeproject.com
 http://tonybierman.blogspot.com/
 http://www.sharepoint-tips.com/
 http://stsadm.blogspot.com/
 Google Groups
Debate - Why use web parts?
Pros
Cons
 Integated part of
 Might work in test
SharePoint
 The developer is provided
with libraries to make the
development of web parts
easier
 Consistens in design
throughtout the web parts
environment but not in
production
 Requires custom
development
 Requires knowledge of the
internal structure in
SharePoint