Here a solution to display the current size of the ViewState inside the browsers statusbar:
protected override void OnPreRenderComplete(EventArgs e)
{
if (DebugFlag)
{
this.ClientScript.RegisterClientScriptBlock(
this.GetType(),
"DisplayViewState",
"<script>window.status = 'ViewState: ' + document.forms[0]['__VIEWSTATE'].value.length + ' bytes';</script>");
}
}
Put this code in your CodeBehind or in your Web-Base-Page (a page derived from System.Web.UI.Page).
If you are not happy with your ViewState Size, take a look at ViewState Numbers and Solutions to reduce ViewState Size as documented here. Keeping the ViewState on the Server (e.g. via SessionState) instead of the client is one way.
No comments:
Post a Comment