Saturday 22 December 2012

Difference between Hidden Field and Viewstate in asp.net. | Vb.Net


In asp.net hidden field and Viewstate both manage memory management.
we can store value in hidden field and viewstate also.
now lets check the difference between both

1->Hidden Field is server control and Viewstate is variable .
2->Hidden field won't visible in browser same for Viewstate but if we will use hidden field ,
 we will get more extra encrypted code in view source whereas if we will use Viewstate we will not get that much of extra code.
3-><input type="hidden" id="hdn" runat="server">
To assign value  to hidden field .. use value property of hidden field
 hdn.Value="sometext" // assingning value  to hidden field
lablet.text=hdn.value   // storing value of hidden field into variable

For viewstate
Viewstate("storeval")="sometext" // assigning value into viewstate
string str=Viewstate("storeval")   //storing value of viewstate into variable
in c# syntax is different.

so in these way we can use hidden field and view state.
hidden field go to the server but Viewstate maintain  after postback whithout touching server.

I don't know whether we can store Datatable value in hidden field but its possible in Viewstate.


Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: