function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nikhil NNikhil N 

please help how to avoid "View State" error in visualforce page???

Prateek Bansal 12Prateek Bansal 12

Hi @Nikhil N 8

Here are some tips to avoid "View State" error

Tips on reducing View State Size:
As we know that total size of ViewState can be 135KB (On date of writing this article), There may be chances that you will hit maximum allowed limit or improve performance of Visualforce page by reducing Viewstate size:

  1. Declare variables as Transient if possible.
  2. Declare variable as Static, as it is not saved in View State.
  3. If you want to manage your own state, instead of using <apex:form> use HTML <form> tag instead.
  4. Recreate state instead of saving in Viewstate. Means if you can use SOQL instead of saving in some object or List, use it.
  5. You can also use Web service call, Ajax Remoting to recreate state instead of saving in Object. 

please let me know if it helps

Regards

Prateek Bansal