Another option is to store the data in viewstate.
ASPX Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="PracticeWeb.WebForm6" %>
<!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:TextBox ID="TextBox1" runat="server" Width="200px"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Click to Compare" />
</div>
</form>
</body>
</html>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PracticeWeb
{
public partial class WebForm6 : System.Web.UI.Page
{
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState.Add("PrevValue",TextBox1.Text);
}
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
string strPrev = Convert.ToString(ViewState["PrevValue"]);
if (strPrev.Equals(TextBox1.Text))
Response.Write("Equal");
else
Response.Write("Not Equal");
}
}
}
}