Monday, August 30, 2010

Viewstate optimization guidelines

1.Use light controls instead of heavy  controls 

  List of Light controls                     

      Lable
      TextBox
      LinkButton
      CheckBox
      RadioButton

Heavy Controls

    DataGrid
    DataList
    Repeater
    ListBox

2.In cases where the page does not need to post back at all, viewstate can be completely eliminated from the page using EnableViewstate="False" in PageDirective


3.Move viewstate to bottom of the page.The reason is  The page would be much more search engine friendly and it would render faster in the browser

4.Disable viewstate for label controls if you are not changing the value of it in code behind .

5.Disable the viewstate for static pages (Which is not having any server controls)
6.I was careful to say that it is "generally" safe to disable view state if you populate the contents of a control each time a page is requested.

No comments: