Huge viewstate on v2.0

J

John

I'm having problems controlling viewstate size in ASP.NET 2.0.

I have a repeater, which contains a gridview, which contains another
gridview. All this is databound to produce a 100page report (for printing).
No postback needed, no viewstate needed.

I've set EnableViewState="false" on everything I can see, including all the
controls, the form and the page itself. But the viewstate is still 10 lines
in notepad (without wrapping!). I assume this is the elusive ControlState
that I can't turn off?

I tried removing the form tag, but that broke the gridviews (they need form
runat="server").

Any ideas? I can serialize the viewstate to session / db, but frankly that's
stupid in this situation - I just don't need ANY viewstate.

Thanks,

John

PS. I suppose I could bodge a PageWithNoViewState class, with a empty
SavePageStateToPersistenceMedium() method. But do I really have to do that??
 
J

John

I wrote the following Page desendent, any better solutions would be
appretiated!

public class NoVSPage : Page
{
protected bool noviewstate = true;

protected override object LoadPageStateFromPersistenceMedium()
{
if (noviewstate)
throw new Exception("This page does not support postback");
else
return base.LoadPageStateFromPersistenceMedium();
}

protected override void SavePageStateToPersistenceMedium(object viewState)
{
if (noviewstate)
return;
else
base.SavePageStateToPersistenceMedium(viewState);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top