Share Point Web Parts 101

  • 2,197 views
Uploaded 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 …

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.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,197
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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