locked
Sharepoint 2010 Save Personalized User scope property which can be changed only by the code RRS feed

  • Question

  • I have a requirement in sp2010 to Save Personalized User scope property which can be changed only via the code.

    I have a Visual webpart where i have defined the below in the usercontrol file.ascx.cs

     private string _MyResources;
    
            [Personalizable(PersonalizationScope.User), WebBrowsable(false)]
            public string MyResourcesProperty
            {
                get { return _MyResources; }
                set { _MyResources = value; }
            } 
    I am updating this from code on button click and fetching it on create child controls but this does not seem to save the user scoped property. Any ideas?


    Pallavi Sharma




    Tuesday, April 17, 2012 6:10 AM

Answers

  • Hi Pallavi,

    You need to add the user control in Cs file in the create child control method.

     protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(ascxPath);
            Controls.Add(control);
        }

    Hope the following link would help you to understand it better.

    http://anyrest.wordpress.com/2011/04/27/creating-visual-web-part-properties/

    Regards


    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful. It'll help other users who are visiting your thread for the similar problem.

    • Marked as answer by Pengyu Zhao Sunday, April 29, 2012 7:41 AM
    Tuesday, April 17, 2012 8:51 AM