SlideShare a Scribd company logo
1 of 31
Download to read offline
Building SharePoint
Web Parts




Rob Windsor
rwindsor@portalsolutions.net
@robwindsor
What Are Web Parts?
• Small “chunks” of user interface and functionality
• Aggregated together to build page content
• Managed by end-users
   Add/remove web parts on a page
   Determine where web parts are placed on the page
   Set web part properties
• Concept and implementation not specific to
  SharePoint or ASP.NET
DEMO
iGoogle
Web Part History
• SharePoint 2003
   First version with web part infrastructure
   Web part types and infrastructure are specific to SharePoint
• ASP.NET 2.0
   Web part types and infrastructure added to ASP.NET
• SharePoint 2007
   Adds support for ASP.NET web parts
   Continues support for SharePoint web parts for backwards
    compatibility
• SharePoint 2010
   Same support as SharePoint 2007 in farm solutions
   Adds support for web parts in sandboxed solutions
Working with SharePoint Web Parts
• Web parts can be added to web part zones or wiki content
• Each web part has common “chrome”
    Title, border, verbs menu
• Closing a web part hides it; deleting a web part removes it
  from page
Web Part Properties
• Web parts properties used to tailor display and functionality
    Zip/Postal code in weather web part
    Stock code in stock ticker web part
• Properties support customization and personalization
    Customization effects shared view of part
    Personalization effects current users view of part
Web Part Gallery
• Site collection scoped
• Both .DWP and .WEBPART files as items
• SharePoint can discover new candidates from
  Web.config
• Maintain metadata
• Available out-of-the-box parts determined by
  edition and site template
Web Part Gallery
DEMO
Working with Web Parts
SharePoint Web Part Page Structure
• Inherits from WSS WebPartPage base class
• Contains one SPWebPartManager control
• Contains one or more WSS WebPartZone controls
          SPWebPartManager


        WebPartZone (Left)   WebPartZone (Right)    Editor Zone

                                                   Editor Part 1
           Web Part 1            Web Part 3

                                                   Editor Part 2
                                 Web Part 4
           Web Part 2

                                                   Catalog Zone
                                 Web Part 5
                                                   Catalog Part 1


                                                   Catalog Part 2
Building a Simple Web Part
• ASP.NET web parts are server controls
    WebPart type derives from Panel
    User interface described with code
• Override RenderContents
    Use HTML markup and JavaScript to build interface
• Override CreateChildControls
    Use Server Controls to build interface
• Two methods can be combined
  protected override void RenderContents(HtmlTextWriter writer)
  {
      writer.RenderBeginTag(HtmlTextWriterTag.H2);
      writer.Write("Hello, World");
      writer.RenderEndTag();
  }
Chrome and Web Part Gallery Properties
• Can set web part properties to change chrome
  values
• Can be done in three places
   Using code in the web part constructor
   Using CAML in the .webpart file
   Editing the web part properties in the browser
• Web part gallery group name set in element
  manifest
DEMO
Building a Simple Web Part
Composite Web Parts
• Contain server controls as children
• Declare controls as fields
• In CreateChildControls
     Create controls
     Set properties
     Add controls to web part Controls collection
     Use LiteralControl to add literal markup
• Populate controls in OnPreRender
Composite Web Parts
protected DropDownList ListsDropDown;
protected GridView ItemsGridView;

protected override void CreateChildControls() {
    ListsDropDown = new DropDownList();
    ListsDropDown.AutoPostBack = true;
    ListsDropDown.SelectedIndexChanged +=
        new EventHandler(ListsDropDown_SelectedIndexChanged);
    Controls.Add(ListsDropDown);
    Controls.Add(new LiteralControl("<br/><br/>"));

    ItemsGridView = new GridView();
    Controls.Add(ItemsGridView);
}
DEMO
Building a Composite Web
Part
Deploying Web Parts
• Add .webpart file to web part gallery
• Register assembly that implements the web part as
  safe control in web.config
• Copy assembly to:
   Global Assembly Cache
   bin folder of IIS Web Application
      Executes with reduced trust
Deploying Web Parts - 2
• Visual Studio tools automate deployment process
  during development
• Visual Studio deployment has conflict detection
   Will replace .webpart file in gallery
• Deployment via Powershell or stsadm does not
  have conflict detection
   Deployed .webpart files will not be replaced
DEMO
Web Part Deployment
Web Parts in Sandboxed Solutions
• Split page rendering
    Page code runs in ASP.NET worker process
    Sandboxed web part code runs in sandbox worker process
    HTML markup and JavaScript from two worker processes merged
• Sandbox restrictions
      Reduced set of server object model API
      Restricted access outside SharePoint
      No elevation of permissions
      Cannot deploy files to SharePoint system folders
      Must be ASP.NET web parts
      Can only use ASP.NET controls
      No web part connections
Visual Web Parts
•    Visual web parts combine a web part with a user control
•    User controls have full design experience in Visual Studio
•    User interface and code behind defined in user control
•    Web part “injects” user control dynamically using
     Page.LoadControl
    private const string _ascxPath = @"~/_CONTROLTEMPLATES/.../MyUserControl.ascx";

    protected override void CreateChildControls()
    {
        Control control = Page.LoadControl(_ascxPath);
        Controls.Add(control);
    }
Visual Web Parts and Sandboxed Solutions
• Native visual web part template not compatible
  with sandboxed solutions
   Attempts to deploy user control to system folders
• Visual Studio Power Tools contains a sandbox
  compatible template
   Markup in the user control is converted to code at design
    time
DEMO
Visual Web Parts
Web Part Properties
• Web Parts support persistent properties
• Configure properties via attributes
    Personalizable(param)
       Directs SharePoint to persist property value
       Parameter indicates if property may be personalized
    WebBrowsable(true)
       Directs SharePoint to generate interface to edit property
    WebDisplayName, WebDescription
       The prompt and tooltip that accompany the data entry element
    Category
       The group in which the properties will be shown

             [Personalizable(PersonalizationScope.Shared)]
             [WebBrowsable(true)]
             [WebDisplayName("Year")]
             [Category("Pluralsight")]
             public int Year { get; set; }
DEMO
Web Part Properties
Deactivating Web Part Features
• Deactivating a Feature that provisions .webpart
  files to the web part gallery effectively does nothing
    Files provisioned by a module are not automatically
     removed on deactivation
    That is, custom web parts remain in the gallery after the
     Feature has been deactivated
• You should add code to the feature receiver to
  remove the .webpart files from the gallery on
  deactivation
Deactivating Web Part Features
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
    var site = properties.Feature.Parent as SPSite;
    if (site == null) return;

    var web = site.RootWeb;
    var list = web.Lists["Web Part Gallery"];

    var partNames = new string[] {
        "Simple.webpart", "Composite.webpart", "Visual.webpart",
        "Sandboxed.webpart", "Properties.webpart"
    };

    foreach (var partName in partNames)
    {
        var item = list.Items.OfType<SPListItem>().
            SingleOrDefault(i => i.Name == partName);
        if (item != null) item.Delete();
    }
}
DEMO
Web Part Properties
Creating Connectable Web Parts
• Pass data from one web part to another
• Loosely-coupled connection
     Communication managed by WebPartManager
     Provider web part supplies data
     Consumer web parts retrieve data
• Interface used to define data contract
     ASP.NET has standard connection contracts
     Can use custom connection contracts
• SharePoint provides user interface elements to establish connections
• Not compatible with sandboxed solutions
Web Part Connections
DEMO
Web Part Connections

More Related Content

What's hot

Oracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersOracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersDataNext Solutions
 
SharePoint 2016 Platform Adoption Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Platform Adoption   Lessons Learned and Advanced TroubleshootingSharePoint 2016 Platform Adoption   Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Platform Adoption Lessons Learned and Advanced TroubleshootingJohn Calvert
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVCIntroduction to ASP.Net MVC
Introduction to ASP.Net MVCSagar Kamate
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvcmicham
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to VisualforceSujit Kumar
 
New Features of ASP.NET 4.0
New Features of ASP.NET 4.0New Features of ASP.NET 4.0
New Features of ASP.NET 4.0Buu Nguyen
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Niit Care
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointRob Windsor
 
SharePoint Development (Lesson 3)
SharePoint Development (Lesson 3)SharePoint Development (Lesson 3)
SharePoint Development (Lesson 3)MJ Ferdous
 
SharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelSharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelPhil Wicklund
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSujit Kumar
 
Sps redmond 2014 deck
Sps redmond 2014 deckSps redmond 2014 deck
Sps redmond 2014 deckDorinda Reyes
 
All About Asp Net 4 0 Hosam Kamel
All About Asp Net 4 0  Hosam KamelAll About Asp Net 4 0  Hosam Kamel
All About Asp Net 4 0 Hosam KamelHosam Kamel
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Niit Care
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practicespaulbowler
 

What's hot (20)

Oracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersOracle ADF Task Flows for Beginners
Oracle ADF Task Flows for Beginners
 
SharePoint 2016 Platform Adoption Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Platform Adoption   Lessons Learned and Advanced TroubleshootingSharePoint 2016 Platform Adoption   Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Platform Adoption Lessons Learned and Advanced Troubleshooting
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVCIntroduction to ASP.Net MVC
Introduction to ASP.Net MVC
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvc
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
 
New Features of ASP.NET 4.0
New Features of ASP.NET 4.0New Features of ASP.NET 4.0
New Features of ASP.NET 4.0
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
 
SharePoint Development (Lesson 3)
SharePoint Development (Lesson 3)SharePoint Development (Lesson 3)
SharePoint Development (Lesson 3)
 
SharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelSharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object Model
 
Oracle ADF Case Study
Oracle ADF Case StudyOracle ADF Case Study
Oracle ADF Case Study
 
ASP.NET 4.0 Roadmap
ASP.NET 4.0 RoadmapASP.NET 4.0 Roadmap
ASP.NET 4.0 Roadmap
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
 
How we rest
How we restHow we rest
How we rest
 
Sps redmond 2014 deck
Sps redmond 2014 deckSps redmond 2014 deck
Sps redmond 2014 deck
 
All About Asp Net 4 0 Hosam Kamel
All About Asp Net 4 0  Hosam KamelAll About Asp Net 4 0  Hosam Kamel
All About Asp Net 4 0 Hosam Kamel
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practices
 

Viewers also liked

Trono di spade1
Trono di spade1Trono di spade1
Trono di spade1jugiu
 
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...SPTechCon
 
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...SPTechCon
 
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...SPTechCon
 
Winchester Bluff Presentation 3_1_13
Winchester Bluff Presentation 3_1_13Winchester Bluff Presentation 3_1_13
Winchester Bluff Presentation 3_1_13bickley2345
 
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...SPTechCon
 
How to best setup SharePoint 2013, Web Apps, Workflow Manager with Powershell
How to best setup SharePoint 2013, Web Apps, Workflow Manager with PowershellHow to best setup SharePoint 2013, Web Apps, Workflow Manager with Powershell
How to best setup SharePoint 2013, Web Apps, Workflow Manager with PowershellSamuel Zürcher
 
Sponsored Session: Driving the business case and user adoption for SharePoint...
Sponsored Session: Driving the business case and user adoption for SharePoint...Sponsored Session: Driving the business case and user adoption for SharePoint...
Sponsored Session: Driving the business case and user adoption for SharePoint...SPTechCon
 
Demystifying share point site definitions SharePoint 2007
Demystifying share point site definitions SharePoint 2007Demystifying share point site definitions SharePoint 2007
Demystifying share point site definitions SharePoint 2007Marwan Tarek
 
Microsoft Keynote by Richard Riley - SPTechCon
Microsoft Keynote by Richard Riley - SPTechConMicrosoft Keynote by Richard Riley - SPTechCon
Microsoft Keynote by Richard Riley - SPTechConSPTechCon
 
SharePoint Search Center Configuration by Matthew McDermott - SPTechCon
SharePoint Search Center Configuration by Matthew McDermott - SPTechConSharePoint Search Center Configuration by Matthew McDermott - SPTechCon
SharePoint Search Center Configuration by Matthew McDermott - SPTechConSPTechCon
 
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...SPTechCon
 
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...SPTechCon
 
Farewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesFarewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesElio Struyf
 
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...SPTechCon
 

Viewers also liked (16)

Trono di spade1
Trono di spade1Trono di spade1
Trono di spade1
 
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...
SharePoint Logging and Debugging: The Troubleshooter’s Best Friend by Jason H...
 
Counseling
CounselingCounseling
Counseling
 
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...
Part II: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTe...
 
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...
SharePoint Performance: Best Practices from the Field by Jason Himmelstein - ...
 
Winchester Bluff Presentation 3_1_13
Winchester Bluff Presentation 3_1_13Winchester Bluff Presentation 3_1_13
Winchester Bluff Presentation 3_1_13
 
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...
Part I: SharePoint 2013 Administration by Todd Klindt and Shane Young - SPTec...
 
How to best setup SharePoint 2013, Web Apps, Workflow Manager with Powershell
How to best setup SharePoint 2013, Web Apps, Workflow Manager with PowershellHow to best setup SharePoint 2013, Web Apps, Workflow Manager with Powershell
How to best setup SharePoint 2013, Web Apps, Workflow Manager with Powershell
 
Sponsored Session: Driving the business case and user adoption for SharePoint...
Sponsored Session: Driving the business case and user adoption for SharePoint...Sponsored Session: Driving the business case and user adoption for SharePoint...
Sponsored Session: Driving the business case and user adoption for SharePoint...
 
Demystifying share point site definitions SharePoint 2007
Demystifying share point site definitions SharePoint 2007Demystifying share point site definitions SharePoint 2007
Demystifying share point site definitions SharePoint 2007
 
Microsoft Keynote by Richard Riley - SPTechCon
Microsoft Keynote by Richard Riley - SPTechConMicrosoft Keynote by Richard Riley - SPTechCon
Microsoft Keynote by Richard Riley - SPTechCon
 
SharePoint Search Center Configuration by Matthew McDermott - SPTechCon
SharePoint Search Center Configuration by Matthew McDermott - SPTechConSharePoint Search Center Configuration by Matthew McDermott - SPTechCon
SharePoint Search Center Configuration by Matthew McDermott - SPTechCon
 
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...
Solving Enterprise Search Challenges with SharePoint 2010 by Matthew McDermot...
 
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
 
Farewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesFarewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display Templates
 
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...
NOW I Get It... What SharePoint Is, and Why My Business Needs It by Mark Rack...
 

Similar to Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor - SPTec…

Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1parallelminder
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemoManishaChothe
 
SharePoint 2010 Training Session 5
SharePoint 2010 Training Session 5SharePoint 2010 Training Session 5
SharePoint 2010 Training Session 5Usman Zafar Malik
 
React.js for Rails Developers
React.js for Rails DevelopersReact.js for Rails Developers
React.js for Rails DevelopersArkency
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webpartsPrabhu Nehru
 
SharePoint Web part programming
SharePoint Web part programmingSharePoint Web part programming
SharePoint Web part programmingQuang Nguyễn Bá
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Vivek chan
 
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Brian Huff
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelAlex Thissen
 
ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916Viral Patel
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WSKatrien Verbert
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22Niit Care
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Nidhi Sharma
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsMohan Arumugam
 
Tech Talk Live on Share Extensibility
Tech Talk Live on Share ExtensibilityTech Talk Live on Share Extensibility
Tech Talk Live on Share ExtensibilityAlfresco Software
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React EcosystemFITC
 
Microsoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยMicrosoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยTeerasej Jiraphatchandej
 

Similar to Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor - SPTec… (20)

Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
 
SharePoint 2010 Training Session 5
SharePoint 2010 Training Session 5SharePoint 2010 Training Session 5
SharePoint 2010 Training Session 5
 
React.js for Rails Developers
React.js for Rails DevelopersReact.js for Rails Developers
React.js for Rails Developers
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webparts
 
SharePoint Web part programming
SharePoint Web part programmingSharePoint Web part programming
SharePoint Web part programming
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916ASP.NET AJAX - 20090916
ASP.NET AJAX - 20090916
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
 
A View about ASP .NET and their objectives
A View about ASP .NET and their objectivesA View about ASP .NET and their objectives
A View about ASP .NET and their objectives
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and Events
 
Tech Talk Live on Share Extensibility
Tech Talk Live on Share ExtensibilityTech Talk Live on Share Extensibility
Tech Talk Live on Share Extensibility
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React Ecosystem
 
Microsoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทยMicrosoft Power Page for Developer - ภาษาไทย
Microsoft Power Page for Developer - ภาษาไทย
 

More from SPTechCon

Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConSPTechCon
 
“Managing Up” in Difficult Situations by Bill English - SPTechCon
“Managing Up” in Difficult Situations by Bill English - SPTechCon“Managing Up” in Difficult Situations by Bill English - SPTechCon
“Managing Up” in Difficult Situations by Bill English - SPTechConSPTechCon
 
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechCon
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechConTen Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechCon
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechConSPTechCon
 
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...SPTechCon
 
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechCon
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechConLaw & Order: Content Governance Strategies by Chrisitan Buckley - SPTechCon
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechConSPTechCon
 
What IS SharePoint Development? by Mark Rackley - SPTechCon
 What IS SharePoint Development? by Mark Rackley - SPTechCon What IS SharePoint Development? by Mark Rackley - SPTechCon
What IS SharePoint Development? by Mark Rackley - SPTechConSPTechCon
 
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConThe SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConSPTechCon
 
Understanding and Implementing Governance for SharePoint 2010 by Bill English...
Understanding and Implementing Governance for SharePoint 2010 by Bill English...Understanding and Implementing Governance for SharePoint 2010 by Bill English...
Understanding and Implementing Governance for SharePoint 2010 by Bill English...SPTechCon
 
Integrate External Data with the Business Connectivity Services by Tom Resing...
Integrate External Data with the Business Connectivity Services by Tom Resing...Integrate External Data with the Business Connectivity Services by Tom Resing...
Integrate External Data with the Business Connectivity Services by Tom Resing...SPTechCon
 
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...SPTechCon
 
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...Tutorial: Best Practices for Building a Records-Management Deployment in Shar...
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...SPTechCon
 
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...SPTechCon
 
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...SPTechCon
 
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...Sponsored Session: Better Document Management Using SharePoint by Roland Simo...
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...SPTechCon
 
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...SPTechCon
 
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechConCreating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechConSPTechCon
 
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...SPTechCon
 
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechCon
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechConBusiness Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechCon
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechConSPTechCon
 
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechCon
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechConPiloting with SharePoint—Learn to FLY by Eric Riz - SPTechCon
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechConSPTechCon
 
Write the Right Requirements by Eric Riz - SPTechCon
Write the Right Requirements by Eric Riz - SPTechConWrite the Right Requirements by Eric Riz - SPTechCon
Write the Right Requirements by Eric Riz - SPTechConSPTechCon
 

More from SPTechCon (20)

Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
 
“Managing Up” in Difficult Situations by Bill English - SPTechCon
“Managing Up” in Difficult Situations by Bill English - SPTechCon“Managing Up” in Difficult Situations by Bill English - SPTechCon
“Managing Up” in Difficult Situations by Bill English - SPTechCon
 
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechCon
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechConTen Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechCon
Ten Best SharePoint Features You’ve Never Used by Christian Buckley - SPTechCon
 
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...
Looking Under the Hood: How Your Metadata Strategy Impacts Everything You Do ...
 
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechCon
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechConLaw & Order: Content Governance Strategies by Chrisitan Buckley - SPTechCon
Law & Order: Content Governance Strategies by Chrisitan Buckley - SPTechCon
 
What IS SharePoint Development? by Mark Rackley - SPTechCon
 What IS SharePoint Development? by Mark Rackley - SPTechCon What IS SharePoint Development? by Mark Rackley - SPTechCon
What IS SharePoint Development? by Mark Rackley - SPTechCon
 
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConThe SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
 
Understanding and Implementing Governance for SharePoint 2010 by Bill English...
Understanding and Implementing Governance for SharePoint 2010 by Bill English...Understanding and Implementing Governance for SharePoint 2010 by Bill English...
Understanding and Implementing Governance for SharePoint 2010 by Bill English...
 
Integrate External Data with the Business Connectivity Services by Tom Resing...
Integrate External Data with the Business Connectivity Services by Tom Resing...Integrate External Data with the Business Connectivity Services by Tom Resing...
Integrate External Data with the Business Connectivity Services by Tom Resing...
 
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...
Converting an E-mail Culture into a SharePoint Culture by Robert Bogue - SPTe...
 
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...Tutorial: Best Practices for Building a Records-Management Deployment in Shar...
Tutorial: Best Practices for Building a Records-Management Deployment in Shar...
 
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...
Tutorial: Building Business Solutions: InfoPath & Workflows by Jennifer Mason...
 
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...
Creating Simple Dashboards Using Out-of-the-Box Web Parts by Jennifer Mason- ...
 
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...Sponsored Session: Better Document Management Using SharePoint by Roland Simo...
Sponsored Session: Better Document Management Using SharePoint by Roland Simo...
 
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...
Sponsored Session: The Missing Link: Content-Aware Integration to SharePoint ...
 
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechConCreating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
 
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...
Tutorial: SharePoint 2013 Admin in the Hybrid World by Jason Himmelstein - SP...
 
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechCon
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechConBusiness Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechCon
Business Intelligence in SharePoint 2013 by Jason Himmelstein - SPTechCon
 
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechCon
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechConPiloting with SharePoint—Learn to FLY by Eric Riz - SPTechCon
Piloting with SharePoint—Learn to FLY by Eric Riz - SPTechCon
 
Write the Right Requirements by Eric Riz - SPTechCon
Write the Right Requirements by Eric Riz - SPTechConWrite the Right Requirements by Eric Riz - SPTechCon
Write the Right Requirements by Eric Riz - SPTechCon
 

Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor - SPTec…

  • 1. Building SharePoint Web Parts Rob Windsor rwindsor@portalsolutions.net @robwindsor
  • 2. What Are Web Parts? • Small “chunks” of user interface and functionality • Aggregated together to build page content • Managed by end-users  Add/remove web parts on a page  Determine where web parts are placed on the page  Set web part properties • Concept and implementation not specific to SharePoint or ASP.NET
  • 4. Web Part History • SharePoint 2003  First version with web part infrastructure  Web part types and infrastructure are specific to SharePoint • ASP.NET 2.0  Web part types and infrastructure added to ASP.NET • SharePoint 2007  Adds support for ASP.NET web parts  Continues support for SharePoint web parts for backwards compatibility • SharePoint 2010  Same support as SharePoint 2007 in farm solutions  Adds support for web parts in sandboxed solutions
  • 5. Working with SharePoint Web Parts • Web parts can be added to web part zones or wiki content • Each web part has common “chrome”  Title, border, verbs menu • Closing a web part hides it; deleting a web part removes it from page
  • 6. Web Part Properties • Web parts properties used to tailor display and functionality  Zip/Postal code in weather web part  Stock code in stock ticker web part • Properties support customization and personalization  Customization effects shared view of part  Personalization effects current users view of part
  • 7. Web Part Gallery • Site collection scoped • Both .DWP and .WEBPART files as items • SharePoint can discover new candidates from Web.config • Maintain metadata • Available out-of-the-box parts determined by edition and site template
  • 10. SharePoint Web Part Page Structure • Inherits from WSS WebPartPage base class • Contains one SPWebPartManager control • Contains one or more WSS WebPartZone controls SPWebPartManager WebPartZone (Left) WebPartZone (Right) Editor Zone Editor Part 1 Web Part 1 Web Part 3 Editor Part 2 Web Part 4 Web Part 2 Catalog Zone Web Part 5 Catalog Part 1 Catalog Part 2
  • 11. Building a Simple Web Part • ASP.NET web parts are server controls  WebPart type derives from Panel  User interface described with code • Override RenderContents  Use HTML markup and JavaScript to build interface • Override CreateChildControls  Use Server Controls to build interface • Two methods can be combined protected override void RenderContents(HtmlTextWriter writer) { writer.RenderBeginTag(HtmlTextWriterTag.H2); writer.Write("Hello, World"); writer.RenderEndTag(); }
  • 12. Chrome and Web Part Gallery Properties • Can set web part properties to change chrome values • Can be done in three places  Using code in the web part constructor  Using CAML in the .webpart file  Editing the web part properties in the browser • Web part gallery group name set in element manifest
  • 14. Composite Web Parts • Contain server controls as children • Declare controls as fields • In CreateChildControls  Create controls  Set properties  Add controls to web part Controls collection  Use LiteralControl to add literal markup • Populate controls in OnPreRender
  • 15. Composite Web Parts protected DropDownList ListsDropDown; protected GridView ItemsGridView; protected override void CreateChildControls() { ListsDropDown = new DropDownList(); ListsDropDown.AutoPostBack = true; ListsDropDown.SelectedIndexChanged += new EventHandler(ListsDropDown_SelectedIndexChanged); Controls.Add(ListsDropDown); Controls.Add(new LiteralControl("<br/><br/>")); ItemsGridView = new GridView(); Controls.Add(ItemsGridView); }
  • 17. Deploying Web Parts • Add .webpart file to web part gallery • Register assembly that implements the web part as safe control in web.config • Copy assembly to:  Global Assembly Cache  bin folder of IIS Web Application  Executes with reduced trust
  • 18. Deploying Web Parts - 2 • Visual Studio tools automate deployment process during development • Visual Studio deployment has conflict detection  Will replace .webpart file in gallery • Deployment via Powershell or stsadm does not have conflict detection  Deployed .webpart files will not be replaced
  • 20. Web Parts in Sandboxed Solutions • Split page rendering  Page code runs in ASP.NET worker process  Sandboxed web part code runs in sandbox worker process  HTML markup and JavaScript from two worker processes merged • Sandbox restrictions  Reduced set of server object model API  Restricted access outside SharePoint  No elevation of permissions  Cannot deploy files to SharePoint system folders  Must be ASP.NET web parts  Can only use ASP.NET controls  No web part connections
  • 21. Visual Web Parts • Visual web parts combine a web part with a user control • User controls have full design experience in Visual Studio • User interface and code behind defined in user control • Web part “injects” user control dynamically using Page.LoadControl private const string _ascxPath = @"~/_CONTROLTEMPLATES/.../MyUserControl.ascx"; protected override void CreateChildControls() { Control control = Page.LoadControl(_ascxPath); Controls.Add(control); }
  • 22. Visual Web Parts and Sandboxed Solutions • Native visual web part template not compatible with sandboxed solutions  Attempts to deploy user control to system folders • Visual Studio Power Tools contains a sandbox compatible template  Markup in the user control is converted to code at design time
  • 24. Web Part Properties • Web Parts support persistent properties • Configure properties via attributes  Personalizable(param)  Directs SharePoint to persist property value  Parameter indicates if property may be personalized  WebBrowsable(true)  Directs SharePoint to generate interface to edit property  WebDisplayName, WebDescription  The prompt and tooltip that accompany the data entry element  Category  The group in which the properties will be shown [Personalizable(PersonalizationScope.Shared)] [WebBrowsable(true)] [WebDisplayName("Year")] [Category("Pluralsight")] public int Year { get; set; }
  • 26. Deactivating Web Part Features • Deactivating a Feature that provisions .webpart files to the web part gallery effectively does nothing  Files provisioned by a module are not automatically removed on deactivation  That is, custom web parts remain in the gallery after the Feature has been deactivated • You should add code to the feature receiver to remove the .webpart files from the gallery on deactivation
  • 27. Deactivating Web Part Features public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPSite; if (site == null) return; var web = site.RootWeb; var list = web.Lists["Web Part Gallery"]; var partNames = new string[] { "Simple.webpart", "Composite.webpart", "Visual.webpart", "Sandboxed.webpart", "Properties.webpart" }; foreach (var partName in partNames) { var item = list.Items.OfType<SPListItem>(). SingleOrDefault(i => i.Name == partName); if (item != null) item.Delete(); } }
  • 29. Creating Connectable Web Parts • Pass data from one web part to another • Loosely-coupled connection  Communication managed by WebPartManager  Provider web part supplies data  Consumer web parts retrieve data • Interface used to define data contract  ASP.NET has standard connection contracts  Can use custom connection contracts • SharePoint provides user interface elements to establish connections • Not compatible with sandboxed solutions