Minimizing viewstate- confused by `EnableViewState` and `ViewStateMode` in asp.net 4.0

前端 未结 1 1478
南方客
南方客 2020-12-31 03:30

I\'m trying to clean up an older ASP.NET WebForms site that has ViewState enabled everywhere. This is a performance issue - huge viewstates cause noticeable submit delays. B

相关标签:
1条回答
  • 2020-12-31 04:15

    As per the MSDN article on ViewStateMode, ViewStateMode only has meaning when EnableViewState="true". To achieve what you want, you'll have to leave ViewStateMode="Enabled" on the control, and then wrap the sub-controls of the main one in an asp:Placeholder that has ViewStateMode="Disabled". That way, you can still manipulate ViewState in the codebehind, but no child control will have ViewState (except the ones you explicitly set to have it via ViewStateMode="Enabled").

    0 讨论(0)
提交回复
热议问题