I am trying to create a custom webpart in point to set and get a property per user on page. To change the background and save it per user.

I'm using code like this:

 public static string SampleColor=blue;
    [Category("Extended Settings"),
    WebDisplayName("Sample Color"),
    WebDescription("Please Enter a Sample Color")]
    public string _SampleText
        get { return SampleText; }
        { SampleColor = value;

This is the property I need.. I will have 3 color buttons.

How can I use it on the page? How can I change it and have it be saved on the site?

2 Answers 2


Create the property as a dropdown box and the Personalization scope should be PersonalizationScope.User. Sample code might look like below.

public enum UserColor
                Blue = Blue,
                Green = Green,
                Yellow = Yellow
            private ItemCount uColor= UserColor.Blue;
            WebDisplayName("Sample Color"),
            WebDescription("Please Enter a Sample Color.")]
            public UserColor ViewColor
                get { return uColor; }
                set { uColor= value; }

Develop the code as described by @Deepu. When you add the web part to a WebPart Page (NOT a wiki page) the users have the option of going to the hidden personal menu and select Personalize this Page and then edit the web part. The only properties they can edit in this mode are the User scoped ones and they only modify them in their personalized view
enter image description here

  • 1
    thx for the Help , But i dont want thant user to get in the Edit Personalize, i want on color button click to change the color and save the selected..\
    – Hassan
    Apr 19, 2012 at 11:47

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.