开发者

sharepoint persistence

开发者 https://www.devze.com 2022-12-16 20:58 出处:网络
开发者_Python百科I\'m pretty new to SharePoint Web Part development, so I\'m not sure the best practices for handling data persistence.In my application, user postbacks will be modifying some underlyi
开发者_Python百科

I'm pretty new to SharePoint Web Part development, so I'm not sure the best practices for handling data persistence. In my application, user postbacks will be modifying some underlying data structure that I would like to maintain rather than rebuild.

The two things I have tried so far are making objects serializable, and storing them in the session array. It seems like there should be a more elegant solution though. I have also tried using custom properties where I set the web browsable attribute to false... although I haven't tried using it for custom classes.

What is the preferred method for data persistence in webparts?

Edit: Here is an example of what I think you are suggesting. First, a class

[Serializable]
    public class foo
    {
        public foo()
        {

        }
    }

Then in my webpart, I would have something like...

public class WebPart : WebControls.WebParts.WebPart
{
    [WebBrowsable(false)]
    [WebPartStorage(Storage.Personal)]
    public foo bar { get; set; }
}

The next problem I seem to have is these values don't seem to persist if I change them programatically. Anything that I expose to the user through the property panel will persist only if the user makes the change. Am I missing something?


You should take a look: ASP.NET Web Parts Overview and Web Parts Personalization Overview. I personally store webparts configuration by using WebPartStorage attribute on public properties from my webpart class.

By default, sessions are disabled on Sharepoint. You should take extra care if you plan to enable it, including performance and stress tests.

0

精彩评论

暂无评论...
验证码 换一张
取 消