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!

1 Answer 1


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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