0

I have three questions:

1. I have turned off ViewState by EnableViewState="false" in page directive, but the HTML output still has hidden inputs which are the ViewState name value pair, so how come hidden inputs still exist after I turn off ViewState? Below is the sourcecode:

<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="HelloWorld.aspx.cs" Inherits="HelloWorld" %>

<!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>
    <h1>ASP.NETT Hello World</h1>
    The ViewState
    <asp:Label ID="labDate" runat="server"/>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" /></form>
</body>
</html>

2. I have 4 textboxs the page, the viewstate is like this:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTgxNTcwMTk2ZGRPm65nTmYHQnzDiOH4z9ojdRdnOQ==" />

so are all textboxes values encoded in this single hidden input?

3.I read a book which says that when an user press a button, "The ASP.NET runtime recognizes that this page is being posted back due to the view state information.". How ASP.NET know it is postback because of viewstate?

  • Show us where you have disabled viewstate in your page. (The actual source code). – mjwills Jul 08 '17 at 13:27
  • @mjwills I have added the source code –  Jul 08 '17 at 13:33
  • 2
    Possible duplicate of [ASP.net ViewState - Even when disabled, some viewstate exist. Why?](https://stackoverflow.com/questions/413558/asp-net-viewstate-even-when-disabled-some-viewstate-exist-why) – mjwills Jul 08 '17 at 13:51

0 Answers0