Alex Rivera | Logout

Enable ViewState for few controls and disable for others/page

Asked 2008-10-09T10:21:32.393
13

When I disable ViewState for the page. It does not allow any other control to use ViewState .. even if I set EnableViewState="true" for that particular control ..

is it possible to enable ViewState for a control when ViewState is disabled for the page itself?

if not how can disable viewstate for controls on page except for few without specifying EnableViewState="false" explicitly .. typing the same into so many controls is hectic ..

Edit
Report

1 Answer

2

The simplest solution is:

<%@ Page Language="C#" EnableViewState="true" ViewStateMode="Disabled" %>

and wherever you want to enable viewstate:

<asp:yourcontrol EnableViewState="true" ViewStateMode="Enabled">

All credits reserved to Shredder's answer on this post

answered 2012-06-19T17:38:21.390

Your Answer