Manikandan
Manikandan

Reputation: 78

How to enableviewstate from code behind for the whole page

I have a page where i have set EnableViewState = 'False', but for certain cases, like CMS admin page, i want the EnableViewState to be set to True from code behind. I tried to put the code in Page_Load, but doesnot seem to work.

Upvotes: 1

Views: 213

Answers (1)

Karl Anderson
Karl Anderson

Reputation: 34846

You need to put that in the page's OnInit event instead of Page_Load. See Page.OnInit Method for more information.

As this ASP.NET Page Lifecycle tutorial shows, the OnInit is your last chance to turn on/off ViewState.

Upvotes: 1

Related Questions