SharePoint Thoughts

Ramblings About SharePoint and Related Technologies

.Net EnableViewState Inheritance from Master Pages

EnableViewState=”true”

Who knew such a simple little tag could cause such a headache. I recently completed a project where Master Pages were being used with ASP.Net Content Placeholders. In one of the content pages, state was not being maintained for any of the controls, and I had explicitly set the viewstate to enabled in every possibly place. It didn’t occur to me after 24 hours of banging my head against the desk, and code intervention from a couple of coworkers did I decide to take a look at the Master Page.

I discovered that no viewstate attributes had been set, and after setting these attributes, poof, it worked as expected, and viewstate was maintained. So the next time your DataGrid, GridView, Repeater, or any other control is not working for you, and you’re using Master Pages, take a look at that master page to make sure you’ve set the EnableViewState attribute. This might save you some time and a headache.

-Isaac

No comments

No comments yet. Be the first.

Leave a reply