Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 09, 2013 08:44 AM by piyush.mall
Jan 04, 2013 12:13 AM|LINK
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.
-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.
Jan 04, 2013 12:28 AM|LINK
Jan 04, 2013 03:58 AM|LINK
Read the following articles
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" %>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" EnableViewState="False"
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
EnableViewState="False" ViewStateMode="Disabled" />
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.
Jan 08, 2013 02:51 AM|LINK
i did some more searching this may explain it alot better.
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