1 minute read

When I started developing for SharePoint two years ago I was thrown in a big black hole and started to develop webparts by hands on experience.
In the first couple of weeks I found out that your webpart could inherit from System.Web.UI.WebControls.WebParts.WebPart or Microsoft.SharePoint.WebPartPages.WebPart.

I never found out the big difference between those two, also never found something on the internet about it besides that they have different serialization formats, besides that it also uses different attributes to give the developer some influence over how properties get displayed and how they are stored.

WSS Backward-Compatibility Comparison Table

ASP.NET Web Parts SharePoint Backwards Compatibility
WebBrowsableAttribute BrowsableAttribute
WebDisplayName FriendlyName
WebDescription Description
Personalizable WebPartStorage
PersonalizationScope Storage
EditorPart ToolPart
EditorPartCollection ToolPart[]
CreateEditorParts() GetToolParts()
RenderContents() RenderWebPart()
SetPersonalizationDirty() SaveProperties
Category Category

 

The question still is: When do we use System.Web.UI.WebControls.WebParts.WebPart or Microsoft.SharePoint.WebPartPages.WebPart?

Microsoft.SharePoint.WebPartPages.WebPart derives from the ASP.NET WebPart class and includes multiple compatibility layers to simplify code migration. This means you should use Microsoft.SharePoint.WebPartPages.WebPart when you are migrating existing code from WSS 2.0. When you are developing new webparts you should use System.Web.UI.WebControls.WebParts.WebPart.

I could recommend you guys to read Inside Microsoft Windows SharePoint Services 3.0 because this information is coming from that book and it is really great book.