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 web part custome setting, defined as below. It works fine but it seem to lose its value once a day!? Is this because the app pool is getting recycled or some such?

Is there anyway to prevent this?

[WebBrowsable(true),
    Personalizable(true),
    WebDisplayName("Site Root"),
    WebDescription("The site root url, so the the webpart can find the SP webservices"),
    Category("Custom Settings"),
    WebPartStorage(Storage.Shared),
    DefaultValue("http://url/")]
    public string SiteRoot
    {
        get { return _siteroot; }
        set
        {
             _siteroot = value;
        }
    }
share|improve this question
    
Someone solved the Problem. I got the same here... :< –  rodin Jul 19 '11 at 11:29
    
are you using content deployment ? –  Steve B Jul 19 '11 at 12:22
    
can you add the declaration of _siteroot too? –  Mauro Jul 19 '11 at 12:24
add comment

4 Answers

Just some suggestions:

Personalizable(true) is equivalent to Personalizable(PersonalizationScope.User). Have you tried Personalizable(PersonalizationScope.Shared)?

WebPartStorageAttribute does not exist in the System.Web.UI.WebControls.WebParts namespace - are you using the older Microsoft.SharePoint.WebPartPages namespace?

share|improve this answer
    
I added this Personalizable(PersonalizationScope.Shared) and removed WebPartStorage but I still get the same behaviour. –  Dan Feb 4 '11 at 14:34
add comment

It has nothing to do with app pool recycles.

A couple of things:

  • You should not use WebPartStorage attribute when building ASP.NET based Web Parts (ie derived from the System.Web.UI.WebControls.WebParts.WebPart). It's superseeded by the Personalizable attribute
  • As SPDoctor says - Personalizable(true) is the same as as Personalizable(PersonalizationScope.User) - which means that every user can personalize the property and having their own values of it
  • Do you do anything with the page before the value is getting reset?
  • Admins/authors can reset user personalized values to the shared value by resetting the web part
  • for more info check out an old post of mine: http://www.wictorwilen.se/Post/Web-Part-Properties-part-1-introduction.aspx
share|improve this answer
    
I added this Personalizable(PersonalizationScope.Shared) and removed WebPartStorage but I still get the same behaviour. I don't think anything is being done on the page. Just seems to happen at regular intervals. –  Dan Feb 4 '11 at 14:36
add comment

I solved the problem by removing the static declaration from the field _siteroot. Since I removed the static declaration no data get lost.

share|improve this answer
add comment

I'm getting a very similar issue at the minute. My web part property Attributes are all kosher, but the part forgets the property settings when someone checks out the page - draft users can't see the property.

Yeah, publishing pages.

share|improve this answer
add comment

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.