State
Management of View State_3 in ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewState3.aspx.cs" Inherits="ASPNETALL.ViewState3" %>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click Me" Font-Bold="False" />
</div>
</form>
</body>
</html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click Me" Font-Bold="False" />
</form>
</body>
</html>
ViewState3.aspx.cs
using System;
public partial class ViewState3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
if (ViewState["Clicks"] == null)
ViewState["Clicks"] = 0;
TextBox1.Text = ViewState["Clicks"].ToString();
}
int ClickCount = (int)ViewState["Clicks"] + 1;
ViewState["Clicks"] = ClickCount;
}
}
0 comments
Post a Comment