0

I have a WebPart where I need to set a custom property in SPWeb.AllProperties. How can I on install check to see if a property is set? If it is not set I want to set it. Or is it best just to do this at the top of my normal WebPart code and run it each time?

0

Use the feature activation event of the feature which the webpart is part of. Get the reference of the SPWeb on Feature activation trap and set the property. and reset during the feature de-activation.

But if there is a possibility of the property getting overridden then check it on every load of the webpart and set the value OR display a error message or set

LINK : http://weblogs.asp.net/bsimser/archive/2008/02/25/getting-sites-and-webs-during-feature-activation-in-sharepoint.aspx

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.