Monday, February 25, 2008

Custom Web Part properties not showing

Just a quick note: if you're having trouble getting your custom properties to show when writing your own Web Part, check which class you're inheriting from. If your Web Part inherits System.Web.UI.WebControls.WebParts.WebPart, try changing this into Microsoft.SharePoint.WebPartPages.WebPart and then test your properties again, they may just work now... (if you haven't made any other mistakes of course ;-))

Update: apparently, you can also get this to work when inheriting from System.Web.UI.WebControls.WebParts.WebPart. To do this, change the line "WebPartStorage(Storage.Personal)" (above your properties) to "Personalizable(PersonalizationScope.User)". If you were using "this.SaveProperties = true" to save the changes done to your properties, this won't be available when inheriting from the System.Web.UI.WebControls.WebParts.WebPart class. You can use this.SetPersonalizationDirty() instead.

No comments: