1. Using ViewState and Session
public partial class _Default : System.Web.UI.Page
{
private bool _refreshState;
private bool _isRefresh;
public bool IsRefresh
{
get
{
return _isRefresh;
}
}
protected override void LoadViewState(object savedState)
{
object[] allStates = (object[])savedState;
base.LoadViewState(allStates[0]);
_refreshState = (bool)allStates[1];
_isRefresh = _refreshState == (bool)Session["__ISREFRESH"];
}
protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] allStates = new object[2];
allStates[0] = base.SaveViewState();
allStates[1] = !_refreshState;
return allStates;
}
protected void Button2_Click(object sender, EventArgs e)
{
if(!IsRefresh)
Response.Write("Thanx for visiting");
}
}
but still exist a problem,,when open two window.