views:

304

answers:

2

VS 2005, ASP.NET with C#, Windows XP, II6

Hi,

Please refer to the topic http://www.codeproject.com/KB/viewstate/SaveViewState.aspx. The topic demonstrates how you can save ViewState to a file system over server so as to make ViewState very small on roundtrips. The author had created a class BasePage by inheriting System.Web.UI.Page and all the pages are derived from this class.

The site i am developing uses a masterpage and all the pages are derived from this masterpage. When i try to override SavePageStateToPersistenceMedium(), a compilation error is generated indicating that there is no such method to override within System.Web.UI.MasterPage.

Does anyone of you have an idea, how could i solve this problem.

Your help is highly appreciated.

Thanks and Regards Irfan

A: 

I have found the solution. Actually the aspx page is derived from System.Web.UI.Page while the masterpage is derived from Control class. There the method SavePageStateToPersistenceMedium() is available within aspx page only not in master page. You have to override this method within each aspx page or create your own base class derived from Page class and then override the method.

IrfanRaza
+1  A: 

Using a PageStatePersister override would be an easier way to change the ViewState persistance mechanism on all pages without requiring a base class.

Milan Negovan has written a good blog post on the different options using the PageStatePersister, with some additional links.

PHeiberg
Thanks PHeiberg! Thats a nice article.
IrfanRaza