开发者

asp.net 2.0 restore entire viewstate

开发者 https://www.devze.com 2023-04-05 09:21 出处:网络
I\'m maintaining a legacy ASP.Net 2.0 webforms applica开发者_开发百科tion, I\'ll spare the details to avoid complicating the question.I just want to ask if anyone knows of a way to efficiently restore

I'm maintaining a legacy ASP.Net 2.0 webforms applica开发者_开发百科tion, I'll spare the details to avoid complicating the question. I just want to ask if anyone knows of a way to efficiently restore an entire viewstate. I can provide more details if necessary, but I'm hoping for something general. I was hoping I could use the Page.LoadPageStateFromPersistenceMedium(), but that appears to be a protected method. Some reading on MSDN seems to indicate I have to use a custom class that inherits from the PageStatePersister Class and use it's methods to restore an entire state. Just wanted to get some input from more experienced developers. Thanks.


there are different approaches for this, we used it once in the past for .NET 2 and worked well.

web.config:

<configuration>
   <system.web>
    <pages pageBaseType="PagePersisterBasePage" />
   </system.web>
</configuration>

page:

public class PagePersisterBasePage : Page
{
    public PagePersisterBasePage()   {
    }
    protected override PageStatePersister PageStatePersister {
        get {
            return new SessionPageStatePersister(this);
        }
    }
} 

just as an example, for full article, worth reading it all, go here: ASP.NET 2.0 Page State Persister


Good article here: http://www.codeproject.com/Articles/7655/Persisting-the-state-of-a-web-page

This restores the ViewState, resets all controls and talks about restoring request.form()

0

精彩评论

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

关注公众号