Thursday, October 2, 2008

Microsoft.SharePoint.WebPartPages.WebPart vs System.Web.UI.WebControls.WebParts.WebPart

So I regularly see people making Web Parts using the Microsoft.SharePoint.WebPartPages.WebPart class instead of the System.Web.UI.WebControls.WebParts.WebPart class. Most of the time people do this because they don't know any better. The Microsoft.Sharepoint one was used for wss 2.0 and it is now recommended that you use the new System.Web.UI.WebControls class (especially since then your web parts will work outside of sharepoint). So the message here is: use System.Web.UI.WebControls.WebParts.WebPart!


That being said, there is one small legitimate use of the Microsoft.SharePoint class (though one that I have never needed to use so far):

The Microsoft.SharePoint.WebPartPages.WebPart class (and NOT the System.Web one) can do:

  • Cross page connections

  • Connections between Web Parts that are outside of a zone

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

  • Data caching infrastructure, including the ability to cache to the database

Just putting that out there for information sake, but as I said, I never not yet needed to do any of those things. I would suggest staying away from it unless you know you need to and don't have a better way.

Remember, SharePoint is NOT all about the Web Parts!

No comments: