Wednesday, March 14, 2007

SharePoint web parts vs ASP.Net 2.0 web parts

When I was setting up my second WSS v3 web part (got HelloWorld to work!) I needed to add in a web part property. I copied in the correct code, but that property just would not appear when I edited the web part settings. The culprit: When developing a web part for WSS v3 or MOSS, make sure to extend Microsoft.SharePoint.WebPartPages.WebPart instead of System.Web.UI.WebControls.WebParts.WebPart. That is:

public class MyWebPart: Microsoft.SharePoint.WebPartPages.WebPart

instead of

public class MyWebPart: System.Web.UI.WebControls.WebParts.WebPart

You might also want to remove the reference to System.Web.UI.WebControls.WebParts from your Using/Imports statements.

No comments: