Web parts for SharePoint
Dec 26, 2015
What’s a web part?Application that can be added to a page
with a web part zone.Inhierits from web controlsCan be developed using C# or VBThe concept of web parts are not just for
SharePoint
Web part lifecycle
Without postback With postback
OnInitOnLoadCreateChildControl
sOnPreRenderRender
OnInitCreateChildContr
olsOnLoadOnPreRenderRender
OnLoadSet the basic layout of the web part like
TitleChrometypeWidth/height
These can also be found in the properties of the web part and be set individually after the web part has been deployed.
RenderRenders the whole web partOnly overwritten i rare situations i case of
special rendering requirements
<name>.xmlAdds the web part to a group in the Web
part GalleryIf a group is not specified, the web part is
placed in the group Miscelleaneous
Create your own propertiesEnables 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 propertiesToolpartsEnables you to add listboxes, peoplepicker,
buttons etc. to the properties.Has it’s own lifecycle similar to a web part.
Time to deployTwo ways to deploy your wsp file:
1. Using install.bat (created by VS for you to use) REMEMBER to change the URL in the install.bat if you
want to install it on a server with a different name.
2. 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-stsadm-operations-with-parameters-in-moss-2007-sp1.aspx
My favorite sites for SharePoint:http://www.codeproject.comhttp://tonybierman.blogspot.com/http://www.sharepoint-tips.com/http://stsadm.blogspot.com/Google Groups
Debate - Why use web parts?
Pros ConsIntegated part of
SharePointThe developer is
provided with libraries to make the development of web parts easier
Consistens in design throughtout the web parts
Might work in test environment but not in production
Requires custom development
Requires knowledge of the internal structure in SharePoint