Home > DeveloperSection > Interviews > What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?

Posted on    November-15-2011 3:10 AM

 SharePoint SharePoint 
Ratings:
 1 Answer(s)
  1709  View(s)
Rate this:

Awadhendra Tiwari

Total Post:510

Points:2550
Posted on    November-15-2011 1:00 AM

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:

1) Cross page connections

2) Connections between Web Parts that are outside of a Web Part zone

3) Client-side connections (Web Part Page Services Component)

4) Data caching infrastructure

Don't want to miss updates? Please click the below button!

Follow MindStick