开发者

Managing ViewState in WebFormsMVP

开发者 https://www.devze.com 2023-01-11 15:21 出处:网络
yesterday i read a very good article about ViewState in ASP.NET. Currently we are using WebFormsMVP to allow better testability in our project. The framework does presenter binding in OnInitComplete

yesterday i read a very good article about ViewState in ASP.NET.

Currently we are using WebFormsMVP to allow better testability in our project. The framework does presenter binding in OnInitComplete and relies heavily on DataBind expressions e.g.

<asp:Label Text="<%#Model.FirstName%>" runat="server" /> 

As i understand above article this would put Model.FirstName into ViewState. Because databinding happens late during page lifecycle when viewstate tracking is already enabled.

One option would be to disable ViewState altogether. Are there any other? Remeb开发者_运维百科er, we can't use OnInit or OnInitComplete, because OnLoad is the first event presenters can handle.

Also keep in mind, that i used the label as example. I'm searching a solution that would also work for complex controls.

Thanks.


After re-reading your question and the article linked, I think the best solution is to create your own set of custom controls as suggested by the article. That way you can get your values in early in the control life-cycle and reduce the injection of viewstate.

Very good article, gives us some things to think about, thanks for posting.

0

精彩评论

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