ASP.NET - ViewState: empty placeholder generates view state
Posted
by
Budda
on Stack Overflow
See other posts from Stack Overflow
or by Budda
Published on 2011-01-01T18:47:26Z
Indexed on
2011/01/01
18:54 UTC
Read the original article
Hit count: 295
On my web-page I have PlaceHolder, not controls are loaded into it.
<asp:PlaceHolder ID="PlaceHolderStatMain" runat="server">
</asp:PlaceHolder>
I am looking the ViewState generated for the page, it is the following:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJLTg1NDkyNTUzD2QWAgIDD2QWAgIND2QWAmYPZBYCAgEPZBYCZg9kFgJmD2QWBmYPFQEYL3N0YXRfc3RhZGl1bS9sZWFndWVfV0VGZAIBDxUBGC9zdGF0X3N0YWRpdW0vbGVhZ3VlX0VFRmQCAg8VARgvc3RhdF9zdGFkaXVtL2xlYWd1ZV9GQ1VkZEuSBUr5LFL6WfCehNBJgjrq0GzwWCWN2qlU70V7LAAb" />
When I set EnableViewState to false:
<asp:PlaceHolder ID="PlaceHolderStatMain" runat="server" EnableViewState="false">
</asp:PlaceHolder>
The viewstate content was decreased significantly:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJLTg1NDkyNTUzZGTTn8Y28VwmpE/K7yPPkLFvhrqMdU8THijFW/BMFzk0tQ==" />
Question: how to remove 'useless' viewstate content without disabling viewstate for placeholder himself (I would like other control loaded into placeholder to has viewstate)?
Is it possible at all?
Any thought are welcome!
P.S. I am using ASP.NET 4.0
© Stack Overflow or respective owner