SharePoint Web Parts 101Silicon Valley Code Camp 2009October 3, 2009 Joseph Ackerman, Senior ConsultantMicrosoft Consultin...
The Ever-Popular Intro Slide<br />Joseph Ackerman (joseph_ackerman@dell.com)<br />20 + years of software development for c...
Agenda<br />Why are we talking about this?<br />User Controls, Server Controls and Web Parts<br />The Steps<br />Deploymen...
Why are we talking about this?<br />SharePoint adoption has exploded over the last couple of years<br />Programmers and So...
User Controls<br />Made up of HTML/ASP page fragments<br />Maybe some code behind<br />Great for breaking up functionality...
Server Controls<br />Harder to write<br />UI elements must be built in code<br />Easier to use across multiple application...
Web Parts<br />Similar to Server Controls<br />Different inheritance tree<br />Some additional requirements for developmen...
Types of Web Parts<br />ASP.Net  Web Parts<br />This is what we will build in our demo today<br />Can be used on ASP.Net a...
The Steps<br />Create a new project (C# windows class library)<br />Sign the assembly<br />References (System.web and Micr...
1. Create a new project<br />C# Class Library project<br />I love VB too, but do yourself a favor and use C# instead – Sha...
2. Sign the Assembly<br />It’s all about trust<br />Allows you to create a strong name for your assembly<br />DELL CONFIDE...
3. Set Your References<br />System.Web<br />Microsoft.SharePoint<br />DELL CONFIDENTIAL<br />12<br />
4. Update assemblyinfo.cs<br />Add a reference to System.Security<br />Allow anonymous users by adding an attribute contai...
5. Update web.config<br />Add your assembly to the SafeControls list<br />Use the full, four-part name<br />DLL name (with...
6. Create your web part classes<br />Your functionality goes here<br />Pick your output method<br />CreateChildControls()<...
7.  Create your .webpart (xml) file<br />Only if you are deploying to the bin folder of your site<br />If you are deployin...
8. Build and Deploy<br />If you are copying your .dll to the GAC, don’t forget to run IISRESET /Restart on your web server...
Best Practices<br />Runtime performance is more important than quick-n-easy development<br />Learn to write real web parts...
Resources<br />Web Parts Resource Center<br />http://msdn.microsoft.com/en-us/sharepoint/bb851483.aspx<br />Instructional ...
Questions?<br />DELL CONFIDENTIAL<br />20<br />
www.dell.com<br />
Upcoming SlideShare
Loading in...5
×

Share Point Web Parts 101

2,307

Published on

SharePoint is being rapidly adopted by enterprises large and small as a platform for collaboration. One of the reasons for this rapid adoption is it's ability to be customized through the development of custom Web Parts. This session will take ASP.Net programmers through all of the steps needed to create a custom Web Part from scratch and make it available to Site creators in their SharePoint environment.

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,307
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Share Point Web Parts 101

  1. 1. SharePoint Web Parts 101Silicon Valley Code Camp 2009October 3, 2009 Joseph Ackerman, Senior ConsultantMicrosoft Consulting Services, GICS, Dell Inc.joseph_ackerman@dell.comSpecial thanks to Shawn Parker for his assistance with this presentation<br />
  2. 2. The Ever-Popular Intro Slide<br />Joseph Ackerman (joseph_ackerman@dell.com)<br />20 + years of software development for clients of all sizes and shapes<br />Wells Fargo<br />Hewlett-Packard<br />Aetna<br />Visa<br />Stanford University<br />Currently consulting as part of Dell’s Microsoft Consulting Services<br />Formerly Allin, Microsoft’s Northwest Region Partner of the Year 2008<br />Most recent project: internal systems for eBay<br />
  3. 3. Agenda<br />Why are we talking about this?<br />User Controls, Server Controls and Web Parts<br />The Steps<br />Deployment Choices<br />The Future<br />Resources<br />DELL CONFIDENTIAL<br />3<br />
  4. 4. Why are we talking about this?<br />SharePoint adoption has exploded over the last couple of years<br />Programmers and Software developers are often presented with the “opportunity” to work with SharePoint because someone in the business (frequently a non-technical person) has made that decision for them <br />If you work in an IT environment that runs on Windows Servers, the chances are pretty good that someone in your organization is already running SharePoint<br />Bottom Line: it’s probably out there already whether you like it or not – but we all like to work, especially in today’s economic climate, right?<br />DELL CONFIDENTIAL<br />4<br />
  5. 5. User Controls<br />Made up of HTML/ASP page fragments<br />Maybe some code behind<br />Great for breaking up functionality within an application<br />Not very portable, hard to re-use<br />DELL CONFIDENTIAL<br />5<br />
  6. 6. Server Controls<br />Harder to write<br />UI elements must be built in code<br />Easier to use across multiple applications<br />DELL CONFIDENTIAL<br />6<br />
  7. 7. Web Parts<br />Similar to Server Controls<br />Different inheritance tree<br />Some additional requirements for development, deployment and use<br />DELL CONFIDENTIAL<br />7<br />
  8. 8. Types of Web Parts<br />ASP.Net Web Parts<br />This is what we will build in our demo today<br />Can be used on ASP.Net and SharePoint pages<br />We’re going to do it from scratch, even though there are some helpful add-on tools<br />SharePoint Web Parts<br />Used in SP 2003; for 2007, DON’T.<br />Data Web Parts<br />Built in; use XSLT to display a data source<br />User Controls wrapped in SmartPart (see CodePlex)<br />Just a wrapper that allows UserControls to behave like web parts<br />Not very secure, Poor performance<br />DELL CONFIDENTIAL<br />8<br />
  9. 9. The Steps<br />Create a new project (C# windows class library)<br />Sign the assembly<br />References (System.web and Microsoft.SharePoint)<br />Update assemblyinfo.cs (for anonymous users)<br />Update web.config with Safecontrol<br />Update/Create the web part classes<br />Update/Create “.webpart” files<br />Build and Deploy<br />DELL CONFIDENTIAL<br />9<br />
  10. 10. 1. Create a new project<br />C# Class Library project<br />I love VB too, but do yourself a favor and use C# instead – SharePoint is not CLS compliant<br />DELL CONFIDENTIAL<br />10<br />
  11. 11. 2. Sign the Assembly<br />It’s all about trust<br />Allows you to create a strong name for your assembly<br />DELL CONFIDENTIAL<br />11<br />
  12. 12. 3. Set Your References<br />System.Web<br />Microsoft.SharePoint<br />DELL CONFIDENTIAL<br />12<br />
  13. 13. 4. Update assemblyinfo.cs<br />Add a reference to System.Security<br />Allow anonymous users by adding an attribute containing AllowPartiallyTrustedCallers()<br />It’s good practice to put your Public Key Token in here as a comment<br />DELL CONFIDENTIAL<br />13<br />
  14. 14. 5. Update web.config<br />Add your assembly to the SafeControls list<br />Use the full, four-part name<br />DLL name (without extension)<br />Version number<br />Culture<br />Namespace<br />Add the TypeName <br />For only one class, use the name<br />For all classes in the namespace, use *<br />Safe should equal “true”<br />DELL CONFIDENTIAL<br />14<br />
  15. 15. 6. Create your web part classes<br />Your functionality goes here<br />Pick your output method<br />CreateChildControls()<br />Add controls to the web part control collection<br />Render()<br />Add HTML to the HTMLTextWriter object parameter <br />DELL CONFIDENTIAL<br />15<br />
  16. 16. 7. Create your .webpart (xml) file<br />Only if you are deploying to the bin folder of your site<br />If you are deploying to the GAC, this is not necessary<br />Where can you find an example of the format?<br />In the web part gallery<br />DELL CONFIDENTIAL<br />16<br />
  17. 17. 8. Build and Deploy<br />If you are copying your .dll to the GAC, don’t forget to run IISRESET /Restart on your web server<br />If you are deploying directly to your web site, make sure that you DLL is in the /bin folder and the .webpart file is in the /wpcatalog folder <br />Both are just off the root of your web site<br />DELL CONFIDENTIAL<br />17<br />
  18. 18. Best Practices<br />Runtime performance is more important than quick-n-easy development<br />Learn to write real web parts, don’t depend on the SmartPart wrapper<br />Common “Base” web part<br />SharePoint object disposal<br />Single-purpose parts and logic<br />Consistent deployment model<br />DELL CONFIDENTIAL<br />18<br />
  19. 19. Resources<br />Web Parts Resource Center<br />http://msdn.microsoft.com/en-us/sharepoint/bb851483.aspx<br />Instructional Video, Module 2: web parts<br />http://www.microsoft.com/winme/0901/34867/mod2/index.html<br />DELL CONFIDENTIAL<br />19<br />
  20. 20. Questions?<br />DELL CONFIDENTIAL<br />20<br />
  21. 21. www.dell.com<br />

×