Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As per my understanding, if viewstate is enabled at the page level, then page will be able to restore control's postback value. Then it is been stored in HTML hidden field name __VIEWSTATE

Now I have following code
XML
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" EnableViewState="true"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" EnableViewState="true"></asp:TextBox>&nbsp;
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:Button ID="Button2" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>



Now enen after and before postback __VIEWSTATE value remain constant as below
XML
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTg4ODA4NDE0NmRkj7tbr766d8QnsN+zf6TsvmqFiao=" />


I think __VIEWSTATE value should be changed after postback if I enter something to textbox.

Please let me know your thought regarding the same.
Posted
Updated 2-Feb-12 1:44am
v2

1 solution

Yes,

You are right!
ViewState can be controlled on page level and at individual asp.net server control...

For more details read this[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900