SlideShare a Scribd company logo
Nguyen Ba Quang
basquang@hotmail.com
http://basquang.spaces.live.com
http://msdnvietnam.net/blogs/quang


SharePoint
Web parts Development
Agenda
●   Web Parts fundamentals
●   Develop simple Web Part using VS 2008
●   Customization and Personalization
●   Design Web Part using VS 2008
●   How to create AJAX and Silverlight Web Parts
●   Web Parts Verbs the new features
●   Web Parts Connections




2    © 2006 Microsoft Corporation.   5/13/2012
3   © 2006 Microsoft Corporation.   5/13/2012
Web Parts Fundamental
● Web Parts are the fundamental building blocks for SharePoint’s
  user interface
● Web Parts are used within the site to enable further
  collaboration or integration within the site context
● There are some built-in Web Part in WSS 3.0 and MOSS 2007
    –   Content Editor Web Part
    –   User Tasks Web Part
    –   XML Web Part
    –   Business Data Catalog Filter Web Part
    –   Search Core Results Web Part
    –   …




4   © 2006 Microsoft Corporation.   5/13/2012
Web Part History
● Windows SharePoint Services 2.0 (WSS)
    – Designed with its own Web Part infrastructure
    – WSS serializes/stores/retrieves personalization data

● ASP.NET 2.0
    –   Designed with newer universal Web Part infrastructure
    –   Serializes/stores/retrieves personalization data
    –   More flexible and more extensible than WSS
    –   ASP.NET 2.0 does not support WSS v2 Web Parts

● Windows SharePoint Services 3.0 (WSS)
    – Backward-compatible with v2 Web Parts
    – Offers a layer on top of the ASP.NET 2.0 Web Part infrastructure


5   © 2006 Microsoft Corporation.   5/13/2012
Web Part Types for WSS v3

       ASP.NET 2.0 Runtime
                                                WSS v3 Runtime

               WSS Web Parts
               ASP Web Parts
                                                  ASP Web Parts


                                                 Hybrid Web Parts
            WSS v2 Runtime
                                                 WSS Web Parts
               WSS Web Parts




6   © 2006 Microsoft Corporation.   5/13/2012
WSS v3 Web Part Page Structure

                SPWebPartManager


           SPWebPartZone (Left)                 SPWebPartZone (Right)    Editor Zone

                    Web Part 1                       Web Part 3         Editor Part 1


                    Web Part 2                       Web Part 4         Editor Part 2


                                                     Web Part 5         Catalog Zone

                                                                        Catalog Part 1


                                                                        Catalog Part 2




7   © 2006 Microsoft Corporation.   5/13/2012
Developing simple Web Part using VS 2008
● Web Parts derive from ASP.NET 2.0 WebPart base class

using System;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

namespace HelloWebPart {
[Guid("91f30b14-2172-4fbf-b0de-d9d28b5e3680")]
  public class HelloWorldWebPart : WebPart {
    protected override void CreateChildControls()   {
        base.CreateChildControls();
       // TODO: add custom rendering code here.
       Label label = new Label();
       label.Text = "Hello World";
       this.Controls.Add(label);}
        }
}


8   © 2006 Microsoft Corporation.   5/13/2012
Develop simple WebPart using VS 2008
● Step 1: Create new Project using SharePoint  WebPart
  template
● Step 2: Override CreateChildControls in webpart classs
● Step 3: Setting your SharePoint URL in Project properties 
  Debug tab  Start Browser with URL
● Step 4: Build and Deploy solution
● Step 5: Ready to test in SharePoint pages




9   © 2006 Microsoft Corporation.   5/13/2012
DEMO
Develop simple Web Part using VS 2008
Customization and Personalization
● Enable Web Parts to be reused for multiple business
  applications
● Customization refers to a change that is shared by all users of
  the Web Part instance.
     – Setting PersonalizationScope.Shared
● Personalization is specific to the individual user’s Web Part
  instance
     – Setting PersonalizationScope.User
● Editor Part is a special type of control that is used only to edit
  Web Part properties that support customization and
  personalization



11   © 2006 Microsoft Corporation.   5/13/2012
Create custom Editor Pad
● Step 1: create new WebPart project
● Step 2: Setting WebBrowsable to false in WebPart properties
● Step 3: Override CreateEditorParts method
● Step 4: Create new class derive from EditorPart
● Step 5: define controls and override CreateChildControls
● Step 6: override ApplyChanges and SyncChanges methods
● Step 7: Setting your SharePoint URL in Project properties 
  Debug tab  Start Browser with URL
● Step 8: Build and Deploy solution
● Step 9: Ready to test in SharePoint pages



12   © 2006 Microsoft Corporation.   5/13/2012
DEMO
Create RSS Reader Web Part
Design Web Part using VS 2008
● Problems:
     – Design UI in Web Part
     – Reuse existing Web pages
● Solutions:
     – Using Web User Control
     – Design using VS 2008
     – Host in Web Part using Page.LoadControl




14   © 2006 Microsoft Corporation.   5/13/2012
Create Web Part host User Controls
● Step 1: Create New WebPart project
● Step 2: Override CreateChildControls
     – Use Page.LoadControl to add UserControls
● Step 3: Create new Web Application project
● Step 4: Create new Web User Controls
● Step 5: Publish the Web Application to
  C:inetpubwwwrootwssVirtualDirectories[port
  number]UserControls
● Step 6: Setting your SharePoint URL in Project properties 
  Debug tab  Start Browser with URL
● Step 7: Build and Deploy WebPart
● Step 8: Ready to test in SharePoint pages

15   © 2006 Microsoft Corporation.   5/13/2012
DEMO
Web Part host User Controls
AJAX and Silverlight Web Part
● Problems:
     – Using AJAX in SharePoint
     – Host Silverlight in SharePoint
● Solutions:
     – Create AJAX and Silverlight in VS 2008
     – Configure SharePoint web.config to enable AJAX and
       Silverlight




17   © 2006 Microsoft Corporation.   5/13/2012
Create AJAX and Silverlight Web Part
● Step 1: config your SharePoint site to work with .NET 3.5
     – Modify in web.config of SharePoint Application
● Step 2: Create new Web Part project in VS 2008
● Step 3: Override OnLoad method to get ScriptManager object
● Step 4: Create AJAX and Silverlight in other project
● Step 5: Deploy your AJAX and Silverlight controls in SharePoint
  folders
● Step 6: Override CreateChildControls to Load AJAX and
  Silverlight controls
     – Use Page.LoadControl to add AJAX user controls
     – Silverlight.Source to load Silverlight controls



18   © 2006 Microsoft Corporation.   5/13/2012
DEMO
AJAX Web Part
Silverlight Web Part
Web Part Verbs
● Web Part Verb is an action that is rendered in the Web Part
  menu by the Web Part framework
● Web Part Verb action support:
     – Client-side function
     – Server-side handler




20   © 2006 Microsoft Corporation.   5/13/2012
Create Web Part Verbs
● Step 1: Create new Web Part project using VS 2008
● Step 2: Override Verbs Properties
public override WebPartVerbCollection Verbs         {
  get             {
        List<WebPartVerb> objVerbs = new List<WebPartVerb>();
        WebPartVerb verb = new WebPartVerb(this.ID, new
WebPartEventHandler(ServerSideHandler));
        verb.Text = "Click to execute server side code";
        verb.Visible = true;
        verb.Description = “Execute server side code";
        objVerbs.Add(verb);
        WebPartVerbCollection allverbs = new
WebPartVerbCollection(base.Verbs, objVerbs);
         return allverbs;
             }
         }


21   © 2006 Microsoft Corporation.   5/13/2012
DEMO
Web Part Verbs
Web Part Connections
● Enables reuse among diverse applications
● Frequently used for master/detail records
● Simple implementation:
     – Implementing custom interface
     – Using ConnectionProvider attribute
     – Using ConnectionConsumer attribute




23   © 2006 Microsoft Corporation.   5/13/2012
Create Connectable Web Part
● Step 1: Create new WebPart project as WebPart provider
● Step 2: Create new Interface
● Step 3: Implement interface in WebPart provider
● Step 4: Specify the data object with the ConnectionProvider
  attribute
● Step 5: Create new WebPart item in your project
● Step 6: Create a connection method with the
  ConnectionConsumer attribute




24   © 2006 Microsoft Corporation.   5/13/2012
DEMO
Web Part Connections
Resource and References

Microsoft SharePoint Products and Technologies Web sites

Web Parts in Windows SharePoint Services MSDN

Inside Microsoft Windows SharePoint Services 3.0 byTed PattisonandDaniel
Larson

Microsoft Office SharePoint 2007 Technical Enablement Tour by Patrick
Tisseghem (Managing Partner – U2U)
Section title here
Sub title here

More Related Content

What's hot (20)

PDF
Building a Next Generation Mobile Browser using Web technologies
n_adam_stanley
 
PDF
Vue js and Vue Material
Eueung Mulyana
 
PDF
Sencha touchonbb10 bootcamp
n_adam_stanley
 
PDF
Asp.net difference faqs- 8
Umar Ali
 
PPTX
Frameworks in java
Darshan Patel
 
PPT
Meet Magento Belarus 2015: Jurģis Lukss
Amasty
 
PDF
Bootstrap Jump Start
Haim Michael
 
PDF
Vue, vue router, vuex
Samundra khatri
 
PDF
Sg conference multiplatform_apps_adam_stanley
n_adam_stanley
 
PDF
WebKit and Blink: open development powering the HTML5 revolution
juanjosanchezpenas
 
PDF
Intro to vue.js
TechMagic
 
PPTX
BlackBerry WebWorks
Bhasker Thapan
 
PPTX
Becoming an IBM Connections Developer
Rob Novak
 
PPSX
01 asp.net session01
Vivek Singh Chandel
 
PPTX
Google app engine by example
Alexander Zamkovyi
 
PPTX
Vuejs getting-started - Extended Version
Murat Doğan
 
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Luciano Mammino
 
PPTX
Deploying applications to Cloud with Google App Engine
Alexander Zamkovyi
 
PDF
KharkivJS: Flaws of the Web Components in 2019 and how to address them
Vlad Fedosov
 
PPTX
Android chromium web view
朋 王
 
Building a Next Generation Mobile Browser using Web technologies
n_adam_stanley
 
Vue js and Vue Material
Eueung Mulyana
 
Sencha touchonbb10 bootcamp
n_adam_stanley
 
Asp.net difference faqs- 8
Umar Ali
 
Frameworks in java
Darshan Patel
 
Meet Magento Belarus 2015: Jurģis Lukss
Amasty
 
Bootstrap Jump Start
Haim Michael
 
Vue, vue router, vuex
Samundra khatri
 
Sg conference multiplatform_apps_adam_stanley
n_adam_stanley
 
WebKit and Blink: open development powering the HTML5 revolution
juanjosanchezpenas
 
Intro to vue.js
TechMagic
 
BlackBerry WebWorks
Bhasker Thapan
 
Becoming an IBM Connections Developer
Rob Novak
 
01 asp.net session01
Vivek Singh Chandel
 
Google app engine by example
Alexander Zamkovyi
 
Vuejs getting-started - Extended Version
Murat Doğan
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Luciano Mammino
 
Deploying applications to Cloud with Google App Engine
Alexander Zamkovyi
 
KharkivJS: Flaws of the Web Components in 2019 and how to address them
Vlad Fedosov
 
Android chromium web view
朋 王
 

Viewers also liked (20)

PPSX
Rbp ph
Leon Policarpio
 
PPT
高一英语必修5 unit 5 first aid using language课件
hangyupeng0319
 
PDF
Magazine TwentseWelle mei 2014
Museum TwentseWelle
 
PDF
SMX Presentation: "Google+: More than a +1 Trick Pony"
Lucia Novara
 
PPTX
Data communication
Md Javedul Ferdous
 
PDF
Outsourced Innovation Case Study-Rose Acre Farm
adambcarney
 
PPT
Prueba
carmenguijarro
 
PPT
Czech competence model
Zuzana Freibergová
 
PPTX
Open innoveren in tijden van schaarste
Vincent Van Malderen
 
PPTX
http://accountants.intorontonow.com
robertwarner02
 
PPTX
Project Open Badges Selor (Belgian Badges)
Vincent Van Malderen
 
PDF
Webデザイントレンドと a-blog cms に組み込みたい実装
takuo yamada
 
PPT
Instructional multimedia project final
crierson
 
PDF
pension jugement
raph98
 
PPTX
Armed forces parade
Robert Bell
 
PPS
Dka 2012
Pravin Sabnis
 
PPSX
Industries sfx11
Pravin Sabnis
 
PPTX
Wireless Sensor Network
Md Javedul Ferdous
 
PDF
Concepciones sobre evolucion
German Chaves
 
PDF
Outsourced Innovation- Cold Storage Research
adambcarney
 
高一英语必修5 unit 5 first aid using language课件
hangyupeng0319
 
Magazine TwentseWelle mei 2014
Museum TwentseWelle
 
SMX Presentation: "Google+: More than a +1 Trick Pony"
Lucia Novara
 
Data communication
Md Javedul Ferdous
 
Outsourced Innovation Case Study-Rose Acre Farm
adambcarney
 
Czech competence model
Zuzana Freibergová
 
Open innoveren in tijden van schaarste
Vincent Van Malderen
 
http://accountants.intorontonow.com
robertwarner02
 
Project Open Badges Selor (Belgian Badges)
Vincent Van Malderen
 
Webデザイントレンドと a-blog cms に組み込みたい実装
takuo yamada
 
Instructional multimedia project final
crierson
 
pension jugement
raph98
 
Armed forces parade
Robert Bell
 
Dka 2012
Pravin Sabnis
 
Industries sfx11
Pravin Sabnis
 
Wireless Sensor Network
Md Javedul Ferdous
 
Concepciones sobre evolucion
German Chaves
 
Outsourced Innovation- Cold Storage Research
adambcarney
 
Ad

Similar to SharePoint Web part programming (20)

PPTX
Parallelminds.web partdemo
ManishaChothe
 
PPTX
Parallelminds.web partdemo1
parallelminder
 
PDF
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
SPTechCon
 
PDF
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
 
PPTX
SharePoint 2010 Training Session 5
Usman Zafar Malik
 
PPSX
15 asp.net session22
Vivek Singh Chandel
 
PPTX
Advanced SharePoint Web Part Development
Rob Windsor
 
PPS
15 asp.net session22
Niit Care
 
PPS
SharePoint 2007 Presentation
Ajay Jain
 
PPT
WSS 3.0 using asp.net 2.0 for extending pages,Server Farms etc..
maddinapudi
 
PPT
Sharepoint
LiquidHub
 
PPT
SharePoint Developer Education Day Palo Alto
llangit
 
PPTX
SharePoint Design & Development
Jonathan Schultz
 
PPTX
SharePoint 2010 Pages
Elliot Chen
 
PPTX
Help! I've got a share point site! Now What?
Becky Bertram
 
PPT
Creating Web Parts New
LiquidHub
 
PPT
Creating Web Parts New
LiquidHub
 
PPT
Creating Web Parts New
LiquidHub
 
PPTX
SoCalCodeCamp SharePoint Server 2010 a Developer Platform
Ivan Sanders
 
PPTX
Popping the Hood: How to Create Custom SharePoint Branding by Randy Drisgill ...
SPTechCon
 
Parallelminds.web partdemo
ManishaChothe
 
Parallelminds.web partdemo1
parallelminder
 
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
SPTechCon
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
 
SharePoint 2010 Training Session 5
Usman Zafar Malik
 
15 asp.net session22
Vivek Singh Chandel
 
Advanced SharePoint Web Part Development
Rob Windsor
 
15 asp.net session22
Niit Care
 
SharePoint 2007 Presentation
Ajay Jain
 
WSS 3.0 using asp.net 2.0 for extending pages,Server Farms etc..
maddinapudi
 
Sharepoint
LiquidHub
 
SharePoint Developer Education Day Palo Alto
llangit
 
SharePoint Design & Development
Jonathan Schultz
 
SharePoint 2010 Pages
Elliot Chen
 
Help! I've got a share point site! Now What?
Becky Bertram
 
Creating Web Parts New
LiquidHub
 
Creating Web Parts New
LiquidHub
 
Creating Web Parts New
LiquidHub
 
SoCalCodeCamp SharePoint Server 2010 a Developer Platform
Ivan Sanders
 
Popping the Hood: How to Create Custom SharePoint Branding by Randy Drisgill ...
SPTechCon
 
Ad

More from Quang Nguyễn Bá (20)

PPTX
Lesson 09 Resources and Settings in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 08 Documents and Printings in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 07 Actions and Commands in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 06 Styles and Templates in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 05 Data Binding in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 04 WPF Controls
Quang Nguyễn Bá
 
PPTX
Lesson 03 Layouts in WPF
Quang Nguyễn Bá
 
PPTX
Lesson 02 Introduction to XAML
Quang Nguyễn Bá
 
PPTX
Lesson 01 Introduction to WPF
Quang Nguyễn Bá
 
PPTX
Business intelligence
Quang Nguyễn Bá
 
PPTX
TDD - Test Driven Dvelopment | Test First Design
Quang Nguyễn Bá
 
PPTX
Scrum sử dụng Team Foundation Server 2012
Quang Nguyễn Bá
 
PPTX
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Quang Nguyễn Bá
 
PPTX
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Quang Nguyễn Bá
 
PPTX
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Quang Nguyễn Bá
 
PPTX
Office 2010 Programming
Quang Nguyễn Bá
 
PPTX
Giới thiệu WCF
Quang Nguyễn Bá
 
PPTX
MOSS 2007 Overview
Quang Nguyễn Bá
 
PPTX
SharePoint Programming Basic
Quang Nguyễn Bá
 
PPTX
SharePoint 2010 Business Intelligence
Quang Nguyễn Bá
 
Lesson 09 Resources and Settings in WPF
Quang Nguyễn Bá
 
Lesson 08 Documents and Printings in WPF
Quang Nguyễn Bá
 
Lesson 07 Actions and Commands in WPF
Quang Nguyễn Bá
 
Lesson 06 Styles and Templates in WPF
Quang Nguyễn Bá
 
Lesson 05 Data Binding in WPF
Quang Nguyễn Bá
 
Lesson 04 WPF Controls
Quang Nguyễn Bá
 
Lesson 03 Layouts in WPF
Quang Nguyễn Bá
 
Lesson 02 Introduction to XAML
Quang Nguyễn Bá
 
Lesson 01 Introduction to WPF
Quang Nguyễn Bá
 
Business intelligence
Quang Nguyễn Bá
 
TDD - Test Driven Dvelopment | Test First Design
Quang Nguyễn Bá
 
Scrum sử dụng Team Foundation Server 2012
Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Quang Nguyễn Bá
 
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Quang Nguyễn Bá
 
Office 2010 Programming
Quang Nguyễn Bá
 
Giới thiệu WCF
Quang Nguyễn Bá
 
MOSS 2007 Overview
Quang Nguyễn Bá
 
SharePoint Programming Basic
Quang Nguyễn Bá
 
SharePoint 2010 Business Intelligence
Quang Nguyễn Bá
 

Recently uploaded (20)

PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 

SharePoint Web part programming

  • 2. Agenda ● Web Parts fundamentals ● Develop simple Web Part using VS 2008 ● Customization and Personalization ● Design Web Part using VS 2008 ● How to create AJAX and Silverlight Web Parts ● Web Parts Verbs the new features ● Web Parts Connections 2 © 2006 Microsoft Corporation. 5/13/2012
  • 3. 3 © 2006 Microsoft Corporation. 5/13/2012
  • 4. Web Parts Fundamental ● Web Parts are the fundamental building blocks for SharePoint’s user interface ● Web Parts are used within the site to enable further collaboration or integration within the site context ● There are some built-in Web Part in WSS 3.0 and MOSS 2007 – Content Editor Web Part – User Tasks Web Part – XML Web Part – Business Data Catalog Filter Web Part – Search Core Results Web Part – … 4 © 2006 Microsoft Corporation. 5/13/2012
  • 5. Web Part History ● Windows SharePoint Services 2.0 (WSS) – Designed with its own Web Part infrastructure – WSS serializes/stores/retrieves personalization data ● ASP.NET 2.0 – Designed with newer universal Web Part infrastructure – Serializes/stores/retrieves personalization data – More flexible and more extensible than WSS – ASP.NET 2.0 does not support WSS v2 Web Parts ● Windows SharePoint Services 3.0 (WSS) – Backward-compatible with v2 Web Parts – Offers a layer on top of the ASP.NET 2.0 Web Part infrastructure 5 © 2006 Microsoft Corporation. 5/13/2012
  • 6. Web Part Types for WSS v3 ASP.NET 2.0 Runtime WSS v3 Runtime WSS Web Parts ASP Web Parts ASP Web Parts Hybrid Web Parts WSS v2 Runtime WSS Web Parts WSS Web Parts 6 © 2006 Microsoft Corporation. 5/13/2012
  • 7. WSS v3 Web Part Page Structure SPWebPartManager SPWebPartZone (Left) SPWebPartZone (Right) Editor Zone Web Part 1 Web Part 3 Editor Part 1 Web Part 2 Web Part 4 Editor Part 2 Web Part 5 Catalog Zone Catalog Part 1 Catalog Part 2 7 © 2006 Microsoft Corporation. 5/13/2012
  • 8. Developing simple Web Part using VS 2008 ● Web Parts derive from ASP.NET 2.0 WebPart base class using System; using System.Web.UI; using System.Web.UI.WebControls.WebParts; namespace HelloWebPart { [Guid("91f30b14-2172-4fbf-b0de-d9d28b5e3680")] public class HelloWorldWebPart : WebPart { protected override void CreateChildControls() { base.CreateChildControls(); // TODO: add custom rendering code here. Label label = new Label(); label.Text = "Hello World"; this.Controls.Add(label);} } } 8 © 2006 Microsoft Corporation. 5/13/2012
  • 9. Develop simple WebPart using VS 2008 ● Step 1: Create new Project using SharePoint  WebPart template ● Step 2: Override CreateChildControls in webpart classs ● Step 3: Setting your SharePoint URL in Project properties  Debug tab  Start Browser with URL ● Step 4: Build and Deploy solution ● Step 5: Ready to test in SharePoint pages 9 © 2006 Microsoft Corporation. 5/13/2012
  • 10. DEMO Develop simple Web Part using VS 2008
  • 11. Customization and Personalization ● Enable Web Parts to be reused for multiple business applications ● Customization refers to a change that is shared by all users of the Web Part instance. – Setting PersonalizationScope.Shared ● Personalization is specific to the individual user’s Web Part instance – Setting PersonalizationScope.User ● Editor Part is a special type of control that is used only to edit Web Part properties that support customization and personalization 11 © 2006 Microsoft Corporation. 5/13/2012
  • 12. Create custom Editor Pad ● Step 1: create new WebPart project ● Step 2: Setting WebBrowsable to false in WebPart properties ● Step 3: Override CreateEditorParts method ● Step 4: Create new class derive from EditorPart ● Step 5: define controls and override CreateChildControls ● Step 6: override ApplyChanges and SyncChanges methods ● Step 7: Setting your SharePoint URL in Project properties  Debug tab  Start Browser with URL ● Step 8: Build and Deploy solution ● Step 9: Ready to test in SharePoint pages 12 © 2006 Microsoft Corporation. 5/13/2012
  • 14. Design Web Part using VS 2008 ● Problems: – Design UI in Web Part – Reuse existing Web pages ● Solutions: – Using Web User Control – Design using VS 2008 – Host in Web Part using Page.LoadControl 14 © 2006 Microsoft Corporation. 5/13/2012
  • 15. Create Web Part host User Controls ● Step 1: Create New WebPart project ● Step 2: Override CreateChildControls – Use Page.LoadControl to add UserControls ● Step 3: Create new Web Application project ● Step 4: Create new Web User Controls ● Step 5: Publish the Web Application to C:inetpubwwwrootwssVirtualDirectories[port number]UserControls ● Step 6: Setting your SharePoint URL in Project properties  Debug tab  Start Browser with URL ● Step 7: Build and Deploy WebPart ● Step 8: Ready to test in SharePoint pages 15 © 2006 Microsoft Corporation. 5/13/2012
  • 16. DEMO Web Part host User Controls
  • 17. AJAX and Silverlight Web Part ● Problems: – Using AJAX in SharePoint – Host Silverlight in SharePoint ● Solutions: – Create AJAX and Silverlight in VS 2008 – Configure SharePoint web.config to enable AJAX and Silverlight 17 © 2006 Microsoft Corporation. 5/13/2012
  • 18. Create AJAX and Silverlight Web Part ● Step 1: config your SharePoint site to work with .NET 3.5 – Modify in web.config of SharePoint Application ● Step 2: Create new Web Part project in VS 2008 ● Step 3: Override OnLoad method to get ScriptManager object ● Step 4: Create AJAX and Silverlight in other project ● Step 5: Deploy your AJAX and Silverlight controls in SharePoint folders ● Step 6: Override CreateChildControls to Load AJAX and Silverlight controls – Use Page.LoadControl to add AJAX user controls – Silverlight.Source to load Silverlight controls 18 © 2006 Microsoft Corporation. 5/13/2012
  • 20. Web Part Verbs ● Web Part Verb is an action that is rendered in the Web Part menu by the Web Part framework ● Web Part Verb action support: – Client-side function – Server-side handler 20 © 2006 Microsoft Corporation. 5/13/2012
  • 21. Create Web Part Verbs ● Step 1: Create new Web Part project using VS 2008 ● Step 2: Override Verbs Properties public override WebPartVerbCollection Verbs { get { List<WebPartVerb> objVerbs = new List<WebPartVerb>(); WebPartVerb verb = new WebPartVerb(this.ID, new WebPartEventHandler(ServerSideHandler)); verb.Text = "Click to execute server side code"; verb.Visible = true; verb.Description = “Execute server side code"; objVerbs.Add(verb); WebPartVerbCollection allverbs = new WebPartVerbCollection(base.Verbs, objVerbs); return allverbs; } } 21 © 2006 Microsoft Corporation. 5/13/2012
  • 23. Web Part Connections ● Enables reuse among diverse applications ● Frequently used for master/detail records ● Simple implementation: – Implementing custom interface – Using ConnectionProvider attribute – Using ConnectionConsumer attribute 23 © 2006 Microsoft Corporation. 5/13/2012
  • 24. Create Connectable Web Part ● Step 1: Create new WebPart project as WebPart provider ● Step 2: Create new Interface ● Step 3: Implement interface in WebPart provider ● Step 4: Specify the data object with the ConnectionProvider attribute ● Step 5: Create new WebPart item in your project ● Step 6: Create a connection method with the ConnectionConsumer attribute 24 © 2006 Microsoft Corporation. 5/13/2012
  • 26. Resource and References Microsoft SharePoint Products and Technologies Web sites Web Parts in Windows SharePoint Services MSDN Inside Microsoft Windows SharePoint Services 3.0 byTed PattisonandDaniel Larson Microsoft Office SharePoint 2007 Technical Enablement Tour by Patrick Tisseghem (Managing Partner – U2U)

Editor's Notes

  • #5: The primary task of the SharePoint developer is to build reusable components for business users. Business users in turn will take these components and build applications, customizing the application for the particular business need and personalizing the application for their own working style. This development mindset is in contrast to typical Windows or Web software that is deployed as a complete unit. With WSS technologies, the application is always evolving as business users employ deployed components to build their own applications and workspaces. Web Parts are used within the site to enable further collaboration or integration within the site context.Web Parts are the fundamental building blocks for SharePoint’s user interface, and with them we can build and integrate many different types of applications. The built-in Web Parts serve as good design examples when writing your own. For example, the Data View Web Part can be configured to point at any data source and display the data in many different ways. In the same way, all of the Web Parts that ship with WSS are generic and built for reuse. Although you may build more specific applications with Web Parts, it is important to be as generic as possible to allow the greatest flexibility for your customer, the business user, who can then configure the Web Part for a specific use.
  • #12: Customization and personalization of Web Parts enable your Web Parts to be reused for multiple business applications. Customization refers to a change that is shared by all users of the Web Part instance, whereas personalization is specific to the individual user’s Web Part instance. For example, the site owner may choose a specific news feed to display on a site’s home page. This would be a customization, because the change would be shared by all users of the site. Individual users on the site may choose different rendering formats according to their preferences, which would be an example of personalization. Personalization applies to individual users and is persisted on a per-user basis.To add a new custom property, just add a public property and the Personalizable attribute. The WebBrowsable, WebDisplayName, WebDescription, and Category attributes also will be useful in administering the property from the Web Part’s Editor Parts. These attributes are defined in the System.Web.UI.WebControls.WebParts and System.ComponentModel namespaces.If you create a property and apply the WebBrowsable attribute, the Web Part framework will automatically display this property in a generic Editor Part when the user selects Modify Web Part. An Editor Part is a special type of control that is used only to edit Web Part properties that support customization and personalization
  • #15: Sometimes you may have an existing Web page application that needs to be ported to SharePoint. It is relatively simple to do this by converting the pages to User Controls. Although User Controls aren’t recommended for all Web Part applications, they can be a quick way to get an ASP.NET application deployed into your SharePoint Web sites. User Controls deployed in SharePoint either must inherit from the UserControl class or from a UserControl-derived class that is available to the Web application (through either the bin directory or the GAC) and must exist in the same IIS Web application. Web Part code then can load the control and add it to your Web Part using the method Page.LoadControl. Since your User Control will exist on the file system and not in the content database, it can contain inline code if needed, since it isn’t processed through the Safe Mode Parser. Note that you cannot deploy User Controls through the content database. You only have to load the control and add it to the controls collection, and the Control framework will render it
  • #18: Enabling .NET 3.5 in SharePoint 2007 Sites (Include AJAX and Silverlight)Start Visual Studio 2008.Create a new dummy ASP.NET Web Application Project, and make sure you target the .NET Framework 2.0 (upper right dropdown of the New Project dialog). The name of this project is not important; you won’t need it anymore when we’re done.Copy the web.configof your SharePoint 2007 site, into the dummy Web Application project in Visual Studio.Open the Project Properties in Visual Studio (right click on the Project node in the Solution Explorer, and choose Properties; or in the Project menu, select WebApplicationX Properties).Select .NET Framework 3.5 in the Target Framework dropdown (select Yes in the confirmation dialog).Copy the web.config from the Web Application Project back to SharePoint.
  • #21: A Web Part Verb is an action that is rendered in the Web Part menu by the Web Part framework as part of the chrome that is rendered around the control. The action can call a client-side function or a server-side handler. To add Web Part Verbs as menu items, override the Verbs property of the Web Part. The Verbs property returns a read-only WebPartVerbCollection, so you will need to merge a collection of Verbs with the base.Verbs property to create a new WebPartVerbCollection.
  • #24: Web Part connections are another Web Part technology that enables reuse among diverse applications. Connections are frequently used for master/detail records and are used in Web Parts for late-bound connections. As long as a Web Part provides data that your Web Part can consume, it can be connected using the Web Part frameworkConnections are enabled through the ConnectionProvider attribute. The simplest way to add a connection to your Web Part is by implementing a custom interface such as the ICustomerProvider interface and specifying the data object with the ConnectionProvider attribute. To connect to the provider Web Part, the consumer Web Part simply marks a connection method with the ConnectionConsumer attribute.