2

In the official documentation for Sharepoint 2010, it says that the ASP.NET web parts (which inherits from the WebPart class in System.Web.UI.WebControls.WebParts) is recommended over the Sharepoint-based Web parts (which inherits from the WebPart class in Microsoft.SharePoint.WebPartPages).

If one is always preferred over the other, why was the Sharepoint-based web parts created in the first place? When is the Sharepoint-based web parts preferred?

5

The SharePoint WebPart has its roots back from the 2003 version where it inherited directly from Control because ASP.NET had no concept of a web part and SharePoint as in many other cases implemented a lot of the functionallity which was moved into ASP.NET 2.0 in order to allow SharePoint to become a real ASP.NET application in 2007.

After ASP.NET 2.0 introduced its WebPart, the SharePoint WebPart base class was reimplemented to inhert from this, but hide the changes the ASP.NET team made from classes inheriting from it. The main reason for it to exist was to ease moving 2003 WebParts to 2007.

That said there is still some functionality which only the SharePoint WebPart base class provides as described in Web Part Infrastructure in SharePoint Foundation

Following is the list of features provided exclusively by the SharePoint WebPart class:

  • Cross page connections
  • Connections between Web Parts that are outside of a Web Part zone
  • Client-side connections (Web Part Page Services Component)
  • A data caching infrastructure that allows caching to the content database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.