I have a windows form where I'm trying to use ViewState but it's not working properly. do you have to enable ViewState in a config file or in the properties of the form
Any examples would be great. thanks
I have a windows form where I'm trying to use ViewState but it's not working properly. do you have to enable ViewState in a config file or in the properties of the form
Any examples would be great. thanks
ViewState
Sameer Murudkar - MSFT
D. Choquette
There's no need for it. After your form's constructor calls the Visual Studio generated InitializeComponent() method (or your hand written equivalent), your Form and its controls are instantiated and can keep their state until the form object is disposed. If you call Show() on your form it'll Dispose when you call Close(). If you call ShowDialog() it will stick around till you call Dispose() on it yourself (this makes it wasy to pop up a dialog asking for input and then retrieving the input in the calling form after the user clicks OK). There's no need to save the state of the form and regenerate it on every button click or other similar event that would require a server round-trip in ASP.Net.
If you need to keep your Form's state outside of that, you save it to a database, the registry, app.config, or some other data structure or storage outside of your form depending on the needs of your app.
Venkatesh SC
Serialization is the closest you come to viewstate in ASP.NET. You serialize the data in the class to disk. This can later be deserialized to create a new instance to contain same data as the time when it was serialized.
http://msdn.microsoft.com/library/en-us/dnadvnet/html/vbnet09252001.asp frame=true
.netNewbieMDS