I have searched this one on Google, but still it is not clear to me!
For example womewhere I read that "EnableViewState enables the viewstate at page level"! But I see that even controls like buttons have "Enable viewstate"!
What I have concluded so far is:
-We can either turn on the enable view state at webconfig for all pages or similarly for a specific page and then we can turn off the viewstatemode of our specific controls' or we can leave it enables by choosing "Enable" or "Inherit"(Which acs identical
to 'enable' in this example, since the page level is 'on') for ViewStateMode.
OR
-we can turn off EnableViewState and here the "Viewstatemode" does not have any effect!
Could you please confirm whether my understanding is right or not? If no please clarify it to me in a simple language.
I have a from, in which I have 1 text box and 1 button control. I have disabled the "EnableViewState" both in page directive and even in webconfig. Also, I have dissabled the "EnableviewState" and "ViewStateMode" of both my controls, but still whenevr I
do postback, the textbox does not lose its value! How come?
This is an excerpt from a book im reading at the moment. It may offer you an explanation.
Controls in ASP.NET have the ability to separate data state and control state. Previous versions of ASP.NET stored data and control state together. When a control's EnableViewState property was set to false, the control lost its appearence data along with
the view state data. in the latest versions of ASP.NET (beyond 2.0), you can set a control's EnableViewState to false and you will turn of the property value data but not the control's appearence information. Of course, this means that a control might still
be contributing to the size of the view state even when the EnableViewState property is set to false.
newcoder61
Member
15 Points
70 Posts
Difference between Enable view state and ViewStateMode
Jan 04, 2013 12:13 AM|LINK
Hi
I have searched this one on Google, but still it is not clear to me!
For example womewhere I read that "EnableViewState enables the viewstate at page level"! But I see that even controls like buttons have "Enable viewstate"!
What I have concluded so far is:
-We can either turn on the enable view state at webconfig for all pages or similarly for a specific page and then we can turn off the viewstatemode of our specific controls' or we can leave it enables by choosing "Enable" or "Inherit"(Which acs identical to 'enable' in this example, since the page level is 'on') for ViewStateMode.
OR
-we can turn off EnableViewState and here the "Viewstatemode" does not have any effect!
Could you please confirm whether my understanding is right or not? If no please clarify it to me in a simple language.
Many thank
oned_gk
All-Star
31766 Points
6492 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 04, 2013 12:28 AM|LINK
http://msdn.microsoft.com/en-us/library/75x4ha6s(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.control.viewstate.aspx
gaurabchatte...
Participant
1663 Points
329 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 04, 2013 03:58 AM|LINK
Read the following articles
http://weblogs.asp.net/sreejukg/archive/2010/04/06/viewstatemode-in-asp-net-4-0.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.page.enableviewstate.aspx
Microsoft Technologies
newcoder61
Member
15 Points
70 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 04, 2013 06:56 AM|LINK
Let me give you an example:
I have a from, in which I have 1 text box and 1 button control. I have disabled the "EnableViewState" both in page directive and even in webconfig. Also, I have dissabled the "EnableviewState" and "ViewStateMode" of both my controls, but still whenevr I do postback, the textbox does not lose its value! How come?
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication301.WebForm1" %> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server" EnableViewState="False" ViewStateMode="Disabled"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" EnableViewState="False" ViewStateMode="Disabled" /> <br /> </div> </form> </body> </html>Myke
Member
60 Points
14 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 08, 2013 02:25 AM|LINK
This is an excerpt from a book im reading at the moment. It may offer you an explanation.
Controls in ASP.NET have the ability to separate data state and control state. Previous versions of ASP.NET stored data and control state together. When a control's EnableViewState property was set to false, the control lost its appearence data along with the view state data. in the latest versions of ASP.NET (beyond 2.0), you can set a control's EnableViewState to false and you will turn of the property value data but not the control's appearence information. Of course, this means that a control might still be contributing to the size of the view state even when the EnableViewState property is set to false.
Myke
Member
60 Points
14 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 08, 2013 02:51 AM|LINK
i did some more searching this may explain it alot better.
http://support.microsoft.com/?id=316813
piyush.mall
Member
208 Points
41 Posts
Re: Difference between Enable view state and ViewStateMode
Jan 09, 2013 08:44 AM|LINK
1. EnableViewState property has options, one--> turn off view state altogether, two -->Enable viewstate for the entire page
2. Turn off ViewState for the entire page and only enable for specified controls, use ViewStateMode property in conjunction with EnableViewState.
3. EnableViewState property only accepts true or false values and the default value is true,
4. ViewStateMode property have value of - Enabled, Disabled and inherit. Inherit is the default
5. ViewStateMode introduced in ASP.NET 4