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
prasad p 18prasad p 18 

what is view state in visual force?

NagendraNagendra (Salesforce Developers) 
Hi Prasad,


View state is a state of your VF page, which help salesforce to regenerate VF page when it comes back from the server

For example, when you create a VF page having a some input fields, no consider that you load this page with some value and there are some required field on this page and when you click on a button this page will get submitted to server then when server replay back your page should be loaded in the same state as it was before submitted button click, to maintain this salesforce exchange data between VF and servers and this information which salesforce maintain is known as View state,

In simple words, it is a state of view which you are view and salesforce use it to regenerate your page whenever their reply comes back from the server

other than transient, you can user VF remoting and @ remote action, as it won't transfer View state

Also, you can user mode=readonly, it a property of <page> tag

Mark this as solved if the reply was helpful.

Thanks,
Nagendra
Ajay K DubediAjay K Dubedi
Hi Prasad,

ViewState holds the state of the visualforce page that holds state that includes the fields,
components and controller state. ViewState data is encrypted and cannot be viewed as tools like firebug.

To maintain state in a Visualforce page, the Force.com platform includes the state of components, field values,
and controller state in a hidden form element. This encrypted string is referred to as the view state and has a limit of 135KB.

you can follow these links to know more about view state:
https://www.salesforcetutorial.com/viewstate-salesforce/
https://developer.salesforce.com/docs/atlas.en-us.salesforce_visualforce_best_practices.meta/salesforce_visualforce_best_practices/pages_best_practices_perf_code_view_state.htm
https://www.jitendrazaa.com/blog/salesforce/introduction-to-view-state-in-visualforce/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi