Monday 26 October 2015

What are the two base classes a WebPart inherit from?

There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the 
SharePoint WebPart Base class 
or the 
ASP.NET 2.0 WebPart base class. 

When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class: 

Cross page connections 
Connections between Web Parts that are outside of a Web Part zone 
Client-side connections (Web Part Page Services Component) 
Data caching infrastructure

No comments: