About the author

Miron Abramson
Software Engineer,
CTO at PixeliT
and .NET addicted for long time.
Open source projects:
MbCompression - Compression library

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2018

Creative Commons License

Blog Flux Directory
Technology Blogs - Blog Top Sites

Optimize your page for UpdatePanel - part II

In the previews post about Optimize your page for UpdatePanel I talked about removing white spaces from the ASPX to optimize the Update Panel callbacks because it can't be compressed as normal response, and thats due the special  format that this response is (it needs to be parse be JS in the client side).

The Update Panel response contain the new html for the specific location that needs to be update and the complete new ViewState for the whole page. So, one more thing we can to optimize the UpdatePanel is to compress the ViewState before it been sent to the client. We don't need to do it in normal response because we use (or should use) a compression module that compress all the page response and that includes the ViewState. Compress the ViewState can save you some more KB from the async response. Another option is to save the ViewState in the server (file os session), and not send it at all. To compress the ViewState we needs to override the 'LoadPageStateFromPersistenceMedium' and the 'SavePageStateToPersistenceMedium' methods that load and save the view state.

Here is the code how to compress the ViewState for the UpdatePanel response only, just copy it to your base page:

 protected override object LoadPageStateFromPersistenceMedium()
    string viewState = Request.Form["__COMPRESSEDVS"];
    if (viewState != null)
         byte[] data = Convert.FromBase64String(viewState);
         data = Utils.Decompress(data);
         LosFormatter lf = new LosFormatter();
         return lf.Deserialize(Convert.ToBase64String(data));
         return base.LoadPageStateFromPersistenceMedium();

protected override void SavePageStateToPersistenceMedium(object viewState)
    if (Utils.IsMsAjaxCallback(Request))
         LosFormatter lf = new LosFormatter();
         using (StringWriter writer = new StringWriter())
             lf.Serialize(writer, viewState);
             string viewStateString = writer.ToString();
             byte[] data = Convert.FromBase64String(viewStateString);
             data = Utils.Compress(data);
             ScriptManager.RegisterHiddenField(this, "__COMPRESSEDVS", Convert.ToBase64String(data));

 (The class 'Utils' can be download here: Utils.cs (1.15 kb))

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Miron on Saturday, November 24, 2007 3:16 AM
Permalink | Comments (14) | Post RSSRSS comment feed

Related posts



Saturday, November 24, 2007 3:23 AM


Trackback from DotNetKicks.com

Optimize your page for UpdatePanel - part II

John Burbidge

Thursday, September 04, 2008 5:37 AM

John Burbidge

I have a user control that contains an update panel and the script fails after a postback. Still useful, I haven't tested but I'm sure if I were to move the update panel to be outside the user control it would work.

Anyway thanks for the pointer.

quotes us

Wednesday, March 18, 2009 3:17 AM


Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of presentation.


Monday, July 13, 2009 5:05 PM


Pingback from weblogs.asp.net

[Link List] Recent (and non recent) Articles on Various Topics - Guru Stop


Saturday, February 13, 2010 9:47 AM


Pingback from blog.gurustop.net

[Link List] Recent (and non recent) Articles on Various Topics | Guru Stop


Tuesday, April 13, 2010 8:30 PM


This i sjust what i was looking for, well presented and written

nouvelles des casinos en ligne in

Thursday, April 22, 2010 10:52 PM

nouvelles des casinos en ligne

A good navigation menu will help users access necessary information quickly and easily.the eye-catching look, it will increase the performance.


Tuesday, May 04, 2010 6:08 PM


Pingback from endyear2012.com

car insurance cheap quote « End Year 2012

My Friends us

Friday, May 07, 2010 8:52 PM

My Friends

I like It

kamal101 ca

Friday, May 14, 2010 3:26 AM


Hello, when i use your persistent viewstate methode, i got this error, because the viewstate seems to be invalid, so it cannot be posted back again to server. I got this error when i click a button (postback) in order to add product to a grid...

and EnableViewState="true"

Line: yy
Erreur : Sys.WebForms.PageRequestManagerServerErrorException: Les informations d'état ne sont pas valides pour cette page et sont peut-être corrompues.

Acai Berry us

Sunday, May 23, 2010 7:54 PM

Acai Berry

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.


Saturday, August 14, 2010 7:23 AM


Pingback from firstcomputer.interactiveinfonet.info

First computer - Computer electronic - Computer first international


Monday, August 23, 2010 7:51 AM


Pingback from grillrestaurant.interactiveinfonet.info

Grill restaurant - Restaurant river - Chain grill montanas restaurant ted


Monday, September 13, 2010 7:44 AM


Pingback from greekart.interactiveinfonet.info

Ancient art greek history - Ancient art - Greek art