views:

30

answers:

1

Hi,

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? Remeber, 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.

A: 

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.

Jim Ross
My point is that i don't understand how to do it in WebFormsMVP. Creating a custom set of custom controls won't get us any further because presenter binding still happens in Page.OnInitComplete. We could put data loading in OnInit but that would miss the point of WebFormsMVP.
Cubicle
Btw, thanks for replying. I almost lost hope to get an answer.
Cubicle