Now, let’s have a look into the changes in ViewState Control in ASP.NET 4.0. There is a massive change in View State Control in ASP.NET 4.0 which is very much helpful for the developer also. ASP.NET 4.0 added a new property to
Page
object and server controls called ViewStateMode
.ViewStateMode
properties has 3 values:Enabled
: This value will enable the view state for page level or control level. This is the default value for thePage
object.Disabled
: This value will disable the viewstate for both page level and control level.Inherit
: This value will make the control inherit the setting of the parent. This is the default value for the server control.
<%@ Page Language="C#" ViewStateMode="Disabled" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="ViewStateDemoLebel1" ViewStateMode="Enabled"
runat="server"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
No comments :
Post a Comment