Web Parts: ASP.NET or WSS


Now that Microsoft Office SharePoint Server 2007 is out, you may have asked yourself this question: which base class should your SharePoint web part inherit from? ASP.NET (System.Web.UI.WebControls.WebParts.WebPart) or Windows SharePoint Services (Microsoft.SharePoint.WebPartPages)?

I found the answer to this question in the Microsoft Windows SharePoint Services 3.0 SDK documentation, Creating Web Parts in Windows SharePoint Services:
"Now that Windows SharePoint Services fully supports the Microsoft ASP.NET 2.0 Web Part infrastructure, you should design Web Parts that inherit from the ASP.NET 2.0 System.Web.UI.WebControls.WebParts.WebPart base class whenever possible. Web Parts such as these are known as ASP.NET Web Parts, and can be used in Windows SharePoint Services applications whether Windows SharePoint Services is involved or not, making them highly reusable..."
"...If you are creating your Web Part specifically for a SharePoint site, and it will consume the Windows SharePoint Services object model, you can derive from the ASP.NET System.Web.UI.WebControls.WebParts.WebPart base class and add a reference to the SharePoint object model in your project."
I've decided to inherit from the ASP.NET web part, because (a) it’s recommended by Microsoft, and (b) it doesn’t stop you from leveraging SharePoint services. To leverage SharePoint services, just drop a reference to the SharePoint object model.

0 comments:

Post a Comment

Aaron Hursman
Aaron Hursman is a passionate user-advocate who is lucky enough to do what he loves for a living. As a user experience architect, he applies user-centered design principles and techniques including user research, persona development, information architecture, storyboards, wireframes, prototyping, visual design, graphic design, interaction design, and usability. Aaron has a background in web development, enterprise applications, and the social web. At nGame, he is applying his craft to design and build the next generation of enterprise software. Aaron is available as a speaker and author upon request.
Disclaimer: The information in this website is provided "as is" with no warranties, and confers no rights. This website does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All instructions and code samples (if any, ever) are provided "as is" without warranty of any kind, either express or implied.