ApplicationState1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationState1.aspx.cs" Inherits="ASPNETALL.ApplicationState1" %>
<!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" />
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationState1.aspx.cs" Inherits="ASPNETALL.ApplicationState1" %>
<!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" />
</div>
</form>
</body>
</html>
ApplicationState1.aspx.cs
using System;
public partial class ApplicationState1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
if (Application["Clicks"] == null)
Application["Clicks"] = 0;
TextBox1.Text = Application["Clicks"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
int ClickCount = (int)Application["Clicks"] + 1;
Application["Clicks"] = ClickCount;
}
}
0 comments
Post a Comment