Why value of Session variable and Application variable updates on page reload !!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace part_5_WebApplication2
{
public partial class Session1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["Click"] == null)
{
Session["Click"] = 0;
}
TextBox1.Text = Session["Click"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int click_count = (int)Session["Click"] + 1;
TextBox1.Text = click_count.ToString();
Session["Click"] = click_count;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
------------------------------------------------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Session1.aspx.cs" Inherits="part_5_WebApplication2.Session1" %>
<!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>