SharePoint Security - ARB SEcurity Solutions
Site Blog Home About ARBBlog SharePoint Dev Center Security Labs Contact
Developing A Form WebPart - Part 1 - Set Up the WebPart Class


Before accomplishing any custom development, the necessary foundational code must be added to the WebPart in order to set it up for inclusion in the SharePoint environment. You must establish the following references (shown in the code listing) in the main WebPartclass file. Doing so allows WebPart class derivation out of the WebPart base class, procures SQL connectivity using ADO.NET 2.0, allows for definition of WebPart attributes, and tolerates the binding of the appropriate user interface controls for final output by an overridden RenderWebPart method.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Xml.Serialization;
using System.Xml;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using System.Collections;

Supply the appropriate WebPart base class inheritance derivation for the parent class either through System.Web.UI.WebControls.WebParts or Microsoft.SharePoint.WebPartPages. For the Form WebPart, it is advisable to use the new ASP.NET 2.0 base class derivation, therefore set the inheritance to System.Web.UI.WebControls.WebParts.WebPart. Once the class has been defined, call the relevant XML decoration attributes in the XmlRoot element provided by the System.Xml.Serialization namespace by defining a default XML namespace in order to control the serialization of the WebPart properties.

Optionally, define the ToolBoxData attribute with the default Typename so that the control class is concretely defined when using it within an IDE. After modifications, your top level class definition should look like the following:

    [DefaultProperty("Text")]
    [ToolboxData("<{0}: FormsWebPart runat=server></{0}: FormsWebPart >")]
    [XmlRoot(Namespace = " ProfessionalSharePoint2007.FormsWebPart ")]
    public class FormsWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
 
 
    }


Since you have now appropriately modified the class in order to assimilate into the WebPart framework and made the necessary references to draw on ADO.NET 2.0 functionality in order to submit user entered items to the backend SQL data store, the relevant child controls need to be instantiated in order to capture user input.




[ Go Back ]
Content ©
 MVP Remote Development

 MVP -- WSS




 TechNet Article

Read my article "7 New Features That Enhance Security In SharePoint" published in the Janurary issue of TechNet magazine Read Now


 Steps To SharePoint Security

Implement Internal SharePoint Security Model

Harden Your Environment With Tools and Policies

Monitor and Supervise With Server Utilities


 SharePoint Security Articles
The Definitive Guide To MOSS Pluggable Authentication Providers
The Active Directory Membership Provider and SharePoint Introduction
Introduction to and Building an ASP.NET 2.0 Custom Session State Provider
Considerations for Security Relating To Configuration Elements
Introduction to Microsoft Office SharePoint Server and WSSv3 Trust Levels and Code Access Security
Example Attack on SharePoint With Chunked Encodes and Overflow

© 2006 ARB Security Solutions, LLC
ARB Security Solutions is not affiliated with or endorsed by Microsoft Corporation.
SharePoint is a trademark of Microsoft Corporation.     Legal Notices | Privacy
SharePointSecurityFooter