Minimize ViewState with TreeView

混江龙づ霸主 提交于 2019-12-08 02:29:47

问题


Any practical tips/tricks on how to do that?

It doesn't seem that there is a lot of information about how to do that. I am loading data from the database into TreeView and the max number of nodes will be around 100. I am still interested in minimizing the ViewState.

I will also be adding and deleting nodes dynamically (though the user interaction).

Thanks!

PS: I am using asp.net 2.0, c#, webforms (so don't give me tips that relate to to ASP MVC only)


回答1:


here is a wonderful way to just get rid of viewstate from being sent over wire for each post-back. basically, it stores the complete viewstate as a session variable on the server and only transfers the identifier in the viewstate field.

compression will save you little bit in terms of bandwidth whereas putting getting viewstate out of the page will have quite dramatic performance improvement

the following articles explains several techniques with performance measurement metrics as well eggheadcafe




回答2:


You can compress it..

http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx

http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx




回答3:


Well you could just stored ViewState in Session and prevent it from going down to the Client at all. Then it'll just be controlstate that's sent up and down which should reduce the page size pretty dramatically...

protected override PageStatePersister PageStatePersister
{
    get
    {
        return new SessionPageStatePersister(this);
    }
}

More info @ this question

Keeping ViewState in SessionPageStatePersister



来源:https://stackoverflow.com/questions/803277/minimize-viewstate-with-treeview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!