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 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
add comment

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"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable, WebDisplayName("Text"),
WebDescription("Enter your text")]
public string Text
{
    get { return text; }
    set 
    {
        // Validate input
        if(value.Length < 10)
            throw new WebPartPageUserException("Enter minimum 10 charectors in text field.");
        text = value;
    }
} 
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.