Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.