I want to know why we must set the serializable attribute to save an object in view state.
Also, which type of objects can we store in view state?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ViewStateis serialized using binary serialization using ObjectStateFormatter. Quote from the documentation:For an object to be binary serializable in the
ViewStateit needs to be decorated with the[Serializable]attribute. So you can put inViewStateany object that has this attribute. Note that simple types like string, int, float, … can also be placed inViewState.