In a web application, I create a viewstate to maintain the value of variable within the page only, can I have anything like viewstate in WinForms, to maintain the values within the forms?
Share
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.
You don’t really need viewstate in Windows Forms because you can store state for example in your main window class using public properties. And as long as your main form lives (which normally is the lifetime of the application) the state will be preserved. If you need to persist the state after the application closes you could store it in files or database.
ViewState is required in ASP.NET because the ASP.NET Form is destroyed after each request and you cannot store instance variables in it. You could use static members but then you get problems as static members are shared among all users of this ASP.NET application.