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 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"),
    Personalizable(PersonalizationScope.Shared),
    WebBrowsable(true),
    WebDisplayName("Sample Color"),
    WebDescription("Please Enter a Sample Color")]
    public string _SampleText
    {
        get { return SampleText; }
        set
        { 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?

share|improve this question
add comment

2 Answers

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;
            [Personalizable(PersonalizationScope.User),
            WebBrowsable(true),
            WebDisplayName("Sample Color"),
            WebDescription("Please Enter a Sample Color.")]
            public UserColor ViewColor
            {
                get { return uColor; }
                set { uColor= value; }
            }
share|improve this answer
add comment

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

share|improve this answer
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 '12 at 11:47
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.