Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose “EnableViewstate” property is “true”.
You can also explicitly add values in it, on an ASP.NET page like:
Viewstate.Add( “TotalStudents”, “87″ );
Viewstate should be used when you want to save a value between different roundtrips of a single page as viewstate of a page is not accessible by another page.
Because Viewstate renders with the page, it consumes bandwidth, so be careful to use it in applications to be run on low bandwidth.
View state is stored on client side ( HTML page in hidden fields ) not on server.
You can store view state in session by using
<configuration>
<system.web>
<browserCaps>
<case>RequiresControlStateInSession=true</case>
</browserCaps>
</system.web>
</configuration>
OR On page
protected override PageStatePersister PageStatePersister
{
get
{
return new SessionPageStatePersister(this);
}
}
sameer.khanjit@gmail.com
View Blog Click "Mark as Answer" on the post that helped you.
thanks for ur answer but i ask a bit different question. in asp.net many server side control is available. i guess not all controls use viewstate to maintain its state during postback. i just need to know the name of those specific server side asp.net controls
which use viewstate to maintain its state. can u name it?
i think this is not true. say for textbox if u disable viewstate for textbox then textbox value maintain during postback but control like gridview must have enable viewstate property should be true otherwise glitches will be there for gridview output.
When you submit a form to a server, the browser always send the field values (those who are named, not disabled and inside the form) to the server. This is how a HTML form works "by design".
The "viewstate" is just an hidden field added by ASP.NET to store extra informations and carry them over accross multiple server side executions of the same page. It doesn't contains field values.
When you make enableviewstate=true then textbox values will be sotered in viewstate.
sameer.khanjit@gmail.com
View Blog Click "Mark as Answer" on the post that helped you.
Marked as answer by mou_inn on Feb 08, 2013 10:57 AM
mou_inn
Participant
783 Points
964 Posts
for which server side control's state are maintain through viewstate
Feb 01, 2013 12:29 PM|LINK
1) asp.net has many server side controls. so just tell me which control's state are maintain through viewstate.
2) without viewstate how can i maintain control and page state. if possible give answer with example and sample code for question number 2. thanks
sameer_khanj...
Star
7554 Points
1466 Posts
Re: for which server side control's state are maintain through viewstate
Feb 05, 2013 12:18 PM|LINK
Viewstate
Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose “EnableViewstate” property is “true”.
You can also explicitly add values in it, on an ASP.NET page like:
Viewstate.Add( “TotalStudents”, “87″ );
Viewstate should be used when you want to save a value between different roundtrips of a single page as viewstate of a page is not accessible by another page.
Because Viewstate renders with the page, it consumes bandwidth, so be careful to use it in applications to be run on low bandwidth.
View state is stored on client side ( HTML page in hidden fields ) not on server.
You can store view state in session by using
<configuration> <system.web> <browserCaps> <case>RequiresControlStateInSession=true</case> </browserCaps> </system.web> </configuration> OR On page protected override PageStatePersister PageStatePersister { get { return new SessionPageStatePersister(this); } }sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
mou_inn
Participant
783 Points
964 Posts
Re: for which server side control's state are maintain through viewstate
Feb 06, 2013 06:03 AM|LINK
thanks for ur answer but i ask a bit different question. in asp.net many server side control is available. i guess not all controls use viewstate to maintain its state during postback. i just need to know the name of those specific server side asp.net controls which use viewstate to maintain its state. can u name it?
can u discuss on this elaborately
<configuration>
<system.web>
<browserCaps>
<case>RequiresControlStateInSession=true</case>
</browserCaps>
</system.web>
</configuration>
OR On page
protected override PageStatePersister PageStatePersister
{
get
{
return new SessionPageStatePersister(this);
}
}
sameer_khanj...
Star
7554 Points
1466 Posts
Re: for which server side control's state are maintain through viewstate
Feb 06, 2013 07:08 AM|LINK
As previosly i menthioned
Viewstate contains state of all server side controls on a page whose “EnableViewstate” property is “true”.
Also from code provided by me you can store viewstate in session instead of on page.
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
mou_inn
Participant
783 Points
964 Posts
Re: for which server side control's state are maintain through viewstate
Feb 08, 2013 05:58 AM|LINK
i think this is not true. say for textbox if u disable viewstate for textbox then textbox value maintain during postback but control like gridview must have enable viewstate property should be true otherwise glitches will be there for gridview output.
sameer_khanj...
Star
7554 Points
1466 Posts
Re: for which server side control's state are maintain through viewstate
Feb 08, 2013 07:44 AM|LINK
When you submit a form to a server, the browser always send the field values
(those who are named, not disabled and inside the form) to the server. This
is how a HTML form works "by design".
The "viewstate" is just an hidden field added by ASP.NET to store extra
informations and carry them over accross multiple server side executions of
the same page. It doesn't contains field values.
When you make enableviewstate=true then textbox values will be sotered in viewstate.
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.