enable viewstate after disabling

S

swesorick

I would like 95% of my site to have the viewstate disabled, in order to
reduce the size of my pages. However, there are about 5% of the pages
on my site that will require viewstate.

Is there any way to make it so that pages have viewstate disabled by
default, but override it to enabled on a page-by-page basis? As of
now, it looks like when i disable the viewstate in my web.config, I
can't re-enable it for the couple pages that need viewstate.

In fact, ideally, I would have viewstate disabled for 99% of the
controls on my pages, and just enable it for a couple controls. It's
such a pain to have to leave it enabled by default and turn it off on a
control by control basis.

I am using ASP.Net 2.0.
 
B

Brock Allen

<pages enableViewState="false"> in web.config, then for those you want to
enable ViewState make sure you have <%@ Page EnableViewState="true" ... %>
 
S

swesorick

That's actually what I tried, first. For some reason, whenever I set
<pages enableViewState="false"> in web.config, it is ignoring the Page
directive: <%@ Page EnableViewState="true" %>

Is this by design, or is there something wrong with my site?
 
J

Juan T. Llibre

By design.

If you set <pages enableViewState="false"> in web.config,
no page directive will work, since EnableViewState was
"turned off" in the application's config file.

OTOH, if you set <pages enableViewState="true"> in web.config,
( which you don't really need to do, since that's the default setting )
then you can turn it *off* in individual pages.
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top