vitale, caturano & company ltd microsoft sharepoint web part development overview vitale,...
TRANSCRIPT
VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
VITALE, CATURANO & COMPANY LTD
SharePoint Developer Series – Web Part Development
.: Michael Williams
:. May 12, 2005
2VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
I. Web Part Essentials
II. Microsoft FrontPage Customization
III. Web Part Development
IV. Resources
V. Questions
Session Agenda
3VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Building blocks for modular web pages Provides connection to information + apps
Built by developers ASP.NET Server Controls
Added to pages by site owners Easy configuration
Personalized by end users Rich and custom client experience
Web Part Essentials
4VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Essentials – Developer Perspective
ASP.NET Server Control based Web Part is a ASP.NET server control
Full power of Visual Studio as a premier development environment Project templates on MSDN Intelli-sense, debugging, source control, etc.
Deployed as an assembly Reusable across thousands of pages and sites Admins control which Web Parts are available End users decide where Web Parts are used
5VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Essentials - Examples
AnnouncementsAnnouncements MembersMembers
EventsEvents
ContactsContacts LinksLinks
6VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Essentials – Tool Parts
7VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
SharePoint Web Page Zones are embedded directly on the page
<SmartPages:WebPartZone runat="server" Title=“Left ZoneID=“…" Orientation="Vertical“
AllowCustomization=“true”
AllowPersonalization=“true”/>
Web Part Essentials – Zones
Database
All users and just for me web parts inside zones are stored in the SharePoint WebParts table
Personalizations stored in the SharePoint Personalization table
8VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Parts are equivalent to ASP.NET Web Form Controls
SmartPage - controls on page determined by database URL of the page ID of the current user (personalization)
SmartPages work in safe mode only
Web Part Essentials – Working Together
ASP.NET Page
Zon
e 2
Zone 1
Zon
e 3
WebPart
Framework
ContentDB
ASP.NET PageWeb Form Controls
9VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Microsoft FrontPage Customization
10VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development - .Net Framework
Custom ASP.Net Web Control derived from System.Web.UI.Control
Base class handles – Page rendering Property settings Post-back events State management
11VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development - .Net Template
Download WebPartTemplatesforVSNetSample.EXE Download WebPartTemplatesforVSNetSample2.EXE
Templates help creation of Web Parts Similar to default server control file and project templates of VS .NET
12VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Create New Web Part Library Project
13VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – The .DWP File
Description Web Part
14VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Web Part Namespace & Class Name
Namespace is MyWebPart1 Class name is WebPart1
namespace MyWebPart1
{
/// <summary>
/// Summary description for WebPart1.
/// </summary>
[DefaultProperty("Text"),ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),XmlRoot(Namespace="MyWebPart1")]
public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart
{
// more code here
15VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Assembly Properties
Assembly name is MyWebPart1 Namespace is MyWebPart1
16VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Remote Server Output Path
If developing against remote machine Set the output path to the remote location's bin directory
17VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – “Hello World!” Code
/// <summary> /// Render this Web Part to the output /// parameter specified. /// </summary> /// <param name="output"> The HTML writer to /// write out to </param> protected override void RenderWebPart(HtmlTextWriter output) { output.Write(SPEncode.HtmlEncode(Text));
//Create a label Label myLabel = new Label();
//Write the text myLabel.Text = "Hello World";
//Add the label control to the page this.Controls.Add(myLabel);
//Render the HTML output myLabel.RenderControl(output); }
18VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Code Access Security
CAS allows box administrators grant specific rights to assemblies Goal is to separate user access rights from the assembly access rights Administrators can
Deny access to local resources for partial trusted assemblies Allocate trust based on signatures, strong names, and certificates
19VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Code Access Security
Provides a safe execution environment for SharePoint & Web Part Pages Only registered assemblies are executed. NO SERVER-SIDE SCRIPT CODE ON SAFE MODE PAGES.
CAS eliminates the following risks - User-inserted code
Infinite loop Memory consumer
Unapproved user-inserted references to Web Form Controls & classes
How to use Safe Mode Install web part assembly in either –
Virtual server’s bin directory Global Assembly Cache (GAC)
On each virtual server – Enable the assembly in the SafeControls list in the web.config file
Administrator optionally enables specific types within the assembly Control will not instantiate during the rendering of the .aspx page if class is marked unsafe or unlisted
20VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Strong Naming Assemblies
Create Key-pair File c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\SN.exe SN –k c:\keypair.snk
Modify Assembly Web Part’s AssemblyInfo.cs Modify [assembly: AssemblyKeyFile(“path\filename”)]
21VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Web Part Deployment
Assembly located in - GAC bin (sub directory under the application root)
Windows SharePoint Services Controls, Namespaces and Assemblies have to be marked as ‘safe’ in web.config Class Resources and .dwp’s deployed to specific locations
Resources are deployed relative to assembly location File System locations –
%AppRoot%\wpcatalog\%AssemblyName% %AppRoot%\wpresources\%AssemblyName% C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources\%AssemblyName%
URL - http://<server>/_wpresources/<AssemblyName>
22VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Web Part Package
Package contains: Manifest.xml Web Part Assemblies Class Resources .DWP’s
Package is a cabinet file (.cab) Create a .cab file using MakeCab.exe
Command-line based Available with Windows .Net Server 2003 Creates web part packages with localized resources
Web Part Packages are deployed using the stsadm.exe tool 3 operations related to Web Part Packages -
AddWPPack EnumWPPacks DeleteWPPack
23VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Web Part Package Manifest
24VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Add “Hello World” Web Part
25VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Debugging Web Parts
Local machine Set <compilation debug=“true”> in web.config of the virtual server Enable ASP.Net debugging Attach to the w3wp.exe process
Remote machine Similar setup steps as debugging a project on a local machine Require permissions to debug on the remote machine (integrated security) Attach to the remote w3wp.exe process
Set start page in Visual Studio .NET that includes the Web Part
26VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Web Part Development – Rendering Overview
ASPX Page
Web Part WebPart.Rende
r()
CustomPart.RenderWebPart()
ASP.NET starts page render
Request
27VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Resources
Microsoft SharePointMicrosoft SharePointhttp://www.microsoft.com/sharepoint
Microsoft SharePoint Server CustomizationMicrosoft SharePoint Server Customizationhttp://www.sharepointcustomization.com/resources/webcasts.htm
Microsoft Developer Introduction to Web PartsMicrosoft Developer Introduction to Web Partshttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_SP2003_ta/html/sharepoint_northwindwebparts.aspsharepoint_northwindwebparts.asp
Microsoft SQL ServerMicrosoft SQL Serverhttp://microsoft.com/sql/default.asp
28VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
Questions?
VITALE, CATURANO & COMPANY LTD
Microsoft SharePoint Web Part Development Overview
29
VITALE, CATURANO & COMPANY PC