Download presentation
Presentation is loading. Please wait.
Published byMarvin Martin Modified over 9 years ago
1
Eric Maurer Copyright Keller Schroder 2008
2
Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions, Version 1.1 Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions, Version 1.2 Includes Projects For Web Parts List Definition Site Definitions Caveats Must run on a SharePoint server No visual designer Be careful when renaming web parts
3
Default constructor Initialize variables and hook up event handlers here Override Create Child Controls Add all controls to the web part’s controls Override Render Contents This method can be overridden to write content directly to the output.
4
SPContext – Current context of the HTTP request SPSite – Site Collection SPContext.Current.Site new SPSite(url) SPWeb – Site Spcontext.Current.Web site.AllWebs[“name”] SPUser – User Web.CurrentUser
5
Do not dispose if using SPContext This is used internally by SharePoint and it will handle disposing of them when the page is closed Use dispose if you are using the “new” methods SPSite site = new Site(http://...), you must dispose of the SPSite and SPWeb if used to prevent memory leaks, by using a using statement or a try, catch, finally block.http://... Also sites or webs created in foreach statements must be disposed. foreach(SPWeb web in site.AllWebs) { //do something here web.Dispose(); }
6
Use the Visual Studio Tools to create a Solution file Use a custom batch file to deploy the web part a feature stsadm.exe -o addsolution -filename webpartpath.wsp stsadm.exe -o deploysolution -immediate -allowGacDeployment -name webpartname.wsp -url http://… -force stsadm.exe -o execadmsvcjobs stsadm.exe -o installfeature -filename webpartname\feature.xml stsadm.exe -o activatefeature –name webpartname -url http://... iisreset
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.