Wednesday, August 11, 2004

Design Days: View State Performance Tips












Design Days: View State Performance Tips

In controls like listbox controls, items added to the list are carried
between client and server via view state... When the list of items become
considerably large it starts hitting the performance and increasing the
traffic between client and server... To avoid this set the EnableViewState
property of the control to be false... By this unnecessary data will not
move back and forth to the server... Though, do note that by doing so your
selected items will no longer remain selected after postback and you will
have to write special code to achieve this functionality...
The same problems are also faced in controls like Datagrid so do ensure that
you use View State judiciously and give enough thoughts while designing your
application...

To see the view state of a page right click on displayed page and 'view
source', here you will see a long line of junk characters for __VIEWSTATE
property... This is the encrypted view state of your controls... Well, that
makes me add one more point the performance... All the viewstate data that
passes to and comes back from server goes through the cycles of encryption
and decryption which in itself is also a costly affair hitting
performance...



Regards,
Mitesh v. Mehta



No comments: