Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2004, 04:14 PM
Authorized User
 
Join Date: Apr 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default LoadViewState

Hi again.

I have a page which contains several controls with some initial settings established. The user can modify those options by choosing others. I would like to know, If I insert a button control to restore the initial settings, can I employ the LoadViewState method to achieve these?

Thanks in advance for any help.



Just reading we'll reach our goals.
__________________
Just reading we\'ll reach our goals.
 
Old June 21st, 2004, 08:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The viewstate is kind of like a snapshot of the state of the controls. It is created each time the page is rendered and lives are part of the form that is drawn onto the page in the HTML. It can't really be used to "restore" a form to its original state. Each time you change or set a property of a control that is on the web form, you affect the viewstate. The viewstate can't be restored due to the stateless nature of the web (which is of course the whole purpose behind viewstate).

If you want to reload a particular page to its original state, all you really need to do is force a clean request to that page. This could be achieved with a hyperlink that goes to that same page, or by some other means of refreshing, except for a standard postback.
 
Old June 22nd, 2004, 07:17 AM
Authorized User
 
Join Date: Apr 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your answer. What about the methods Page.LoadPageStateFromPersistenceMedium and Page.SaveStateToPersistenceMedium?
Can I use this methods to achieve this?



Just reading we'll reach our goals.
 
Old June 22nd, 2004, 07:42 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I doubt that will help, as that is still viewstate.

You'll need to do as I suggested above, or somehow manually save the state of the page/controls so you can retrieve then later. I don't imagine this would be that easy because of the multitude of control attributes.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.