ASP.Net Web Controls and Web Parts

Category: Education

Presentation Description



Presentation Transcript

ASP.Net Server Controls and Sharepoint 2003 Web Parts:

ASP.Net Server Controls and Sharepoint 2003 Web Parts Presented by Paul Turner [email protected]


Overview What is a control? The 3 types of ASP.Net Controls Web User Controls Rendered Server Controls Composite Server Control Sharepoint Portal Server 2003 Intro to Sharepoint Web Parts from ASP.Net Server Controls Web Part deployment Traditional ASP.Net in Sharepoint 2003

What is a Control?:

What is a Control? A reusable piece of UI Encapsulates functionality Contains logic Can contain other controls Initialized after the page loads

Web User Controls:

Web User Controls Design: Simple skills required Designed visually in the IDE No design time view Reusability: Low must be included in any project you want to use them in

Web User Controls Demo:

Web User Controls Demo

Web User Controls – Summary:

Web User Controls – Summary Added within an ASP.Net Application Add new item… Web User Control Create your UI and Logic Drag/Drop on to ASPX pages

Rendered Server Controls:

Rendered Server Controls Design: Moderate to Expert skills required Completely render HTML Must handle events by implementing interfaces Full design time support Reusability: Very Good Just add it to the toolbox

Rendered Control Demo:

Rendered Control Demo

Rendered Control - Summary:

Rendered Control - Summary Create a new ASP.Net Web Control Project Ensure your class inherits from System.Web.UI.WebControls.WebControl Add using System.Web.UI; into your AssemblyInfo.cs Add TagPrefix into your AssemblyInfo.cs Set AssemblyVersion in your AssemblyInfo.cs

Rendered Control - Summary:

Rendered Control - Summary Use the [..] tags i.e. [Description(“..”)] Override the Render method Implement interfaces as required Add a Toolbox Icon Compile the assembly Add it to the toolbox of any project you want to use it in

Composite Server Controls:

Composite Server Controls Design: Moderate skills required Use standard ASP.Net controls Use standard delegates to handle events Full design time support Reusability: Very Good Just add it to the toolbox

Composite Control Demo:

Composite Control Demo

Composite Control - Summary:

Composite Control - Summary Same as Rendered Control but… Override CreateChildControls Create standard ASP.Net objects Add them to the Controls Collection Call EnsureChildControls before calling methods/properties Don’t need to override the Render method

Composite Controls – Sidebar:

Composite Controls – Sidebar Why would I use a Composite control? Easier… No need to implement interfaces Can I combine a Composite control with a Rendered control? YES…

Sharepoint Portal Server 2003:

Sharepoint Portal Server 2003 Sharepoint Portal Server (SPS) is a portal solution that provides document management and searching facilities Provides a portal infrastructure such as membership services, security (via Audiences), and more… SPS 2003 is based on .Net The portal infrastructure can be used for other things by creating WebParts

SPS Demo:

SPS Demo


WebParts Introduced with the Microsoft Digital Dashboard initiative First version was designed for SPS 2001 Now in SPS 2003 WebParts are based on ASP.Net Very similar to ASP.Net server controls

WebPart prerequisites:

WebPart prerequisites Get SPS 2003 Get the Microsoft.Sharepoint.* assemblies Install the WebParts Templates for VS.Net Downloadable from the Microsoft Web site

Moving to Webparts:

Moving to Webparts Use VS.Net (templates are only available for VB.Net and C#.Net) Create a new WebPart project Use your knowledge of ASP.Net server controls to construct the WebParts functionality Create a Setup CAB project Use the SPS deployment tools

Create a WebPart Demo:

Create a WebPart Demo

WebParts - Summary:

WebParts - Summary Same as Rendered Controls but… Add: using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; using Microsoft.SharePoint.WebPartPages; Set [XmlRoot(Namespace=“..”)] for the class

WebParts - Summary:

WebParts - Summary Ensure your class inherits from Microsoft.SharePoint.WebPartPages.WebPart Set WebPartStorage(…) for the properties Personal – Per user Shared – Global None – Not stored Override RenderWebPart (same as Render method in standard Server controls)

WebParts - Summary:

WebParts - Summary If you override CreateChildControls you must call the RenderChildren method in the RenderWebPart method Create a Strong Name using sn.exe Set AssemblyKeyFile into your AssemblyInfo.cs to the *.snk file generated by sn.exe

Deploying WebParts:

Deploying WebParts Create a CAB file project Use the Spsadmin tool in SPS to install the WebPart in to the Virtual Server WebPart collection Uninstall by using Spsadmin Edit the page and add the WebPart to a Zone

Deployment Demo:

Deployment Demo

Traditional ASP.Net in SPS:

Traditional ASP.Net in SPS You can use traditional ASP.Net in SPS Create an IIS Virtual directory under: C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS Configure it to run under MSSharePointPortalAppPool

Traditional ASP.Net in SPS:

Traditional ASP.Net in SPS Access the pages via the _layouts path Turn on ‘Session’ if you need it (SPS turns it off by default) in the web.config in the ..\TEMPLATE\LAYOUTS directory A Web Setup project will do it all for you!!!

ASP.Net Demo:

ASP.Net Demo


Summary Controls are reusable pieces of UI and logic Web User Controls are easy to create but cannot be easily reused Composite Controls are the next best option


Summary WebParts are very similar to Composite/Rendered Controls but have a different base class Use the SPS deployment tool and VS.Net to create CAB projects Get into the habit of creating setup projects for ALL your applications


Summary ‘Tip of the Iceberg’ Lots more on ASP.Net Controls Lots more on SPS Web Parts Custom toolbox properties Connectable Web Parts Lots more on Setup projects