Viewstate or hidden field better than

Posted by Murugavelmsc under Interview Questions on 2/11/2013 | Points: 10 | Views : 5154 | Status : [Member] | Replies : 4
Hi All,


Viewstate or hidden field better than? why?

Thanks,
Murugavel S

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

Posted by: Satyapriyanayak on: 2/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://www.codeproject.com/Articles/101888/ViewState-Various-ways-to-reduce-performance-overh
http://stackoverflow.com/questions/4773126/hidden-field-vs-viewstate

If this post helps you mark it as answer
Thanks

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 2/13/2013 [Member] Starter | Points: 25

Up
0
Down
Viewstate increase memory allocation on server...so its good to disable viewstate..so i go for hidden field

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kusumas on: 2/13/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

ViewState is stored in a hidden field and it contains information about the entire page. It can also be encrypted. Because the view state is always sent to the codebehind when performing Postbacks it is very practical as you always get the values. The drawback is that it can get really large if you start putting much information inside it and performance could start to suffer. For example in some AJAX requests you want to only send some small information to the server and if you used UpdatePanels the entire ViewState will be sent and it will contain information that is not necessary.



Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kusumas on: 2/13/2013 [Member] Starter | Points: 25

Up
0
Down
hidden field :

The hidden field does not show, but still, when the form is submitted the hidden field is sent with it.Therefore the visitor can't type anything into a hidden field but we can assign values. getting values in post back or on page load.

View state:

To store values between postbacks in ASP.NET we go for viewstate ie

When a postback happens (i.e. when a form is submitted to a server), the variable values that are set in the code-behind page are erased from the memory of the client system. This concept would be different from what happens in Windows-based applications, where the variables persist in memory until they are freed from the memory either by the garbage collector, or by specific codes like dispose or finalize.
In web applications, variable values simply get erased. But it is very simple to persist these values. They may be persisted using the Viewstate object. Before the postback is invoked, the variable's value is saved in a viewstate object. In the same page, the viewstate's value may be retrieved back after hitting the server and returns back

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response