SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developping a web part that customizes the SharePoint Ribbon (hide or show buttons).

Can I store some properties in a separate file? If the web part is active on three sites, I should have three separate files because it can have different settings.

I don't want to make use of the property panel from the web part because power users will eventually do something wrong.

Is this possible and how should I do it.

Thanks in advance!

share|improve this question

This sounds like it could be classed as configuration data. This msdn article - Managing Application Configuration - describes the options available to you.

Basically you can store the properties in either:

  • web.config
  • hierarchical object store
  • property bag
  • list

I'd therefore recommend a list which is secured so only certain people can access it.

However, if the settings aren't site wide, those will prove problematic as you won't know how many times the web part is used and therefore won't be able to easily create a storage place for each instance.

I would therefore recommend implementing some property validation to stop invalid values, for example:

public string text;

[Category("Advanced Settings"),
WebBrowsable, WebDisplayName("Text"),
WebDescription("Enter your text")]
public string Text
    get { return text; }
        // Validate input
        if(value.Length < 10)
            throw new WebPartPageUserException("Enter minimum 10 charectors in text field.");
        text = value;
share|improve this answer

Your Answer


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.