step1) declare two variable
private bool _refreshState;
private bool _isRefresh;
step2) write down following code
protected override void LoadViewState(object savedState)
{
object[] AllStates = (object[])savedState;
base.LoadViewState(AllStates[0]);
_refreshState = Convert.ToBoolean(AllStates[1].ToString());
_isRefresh = (_refreshState == Convert.ToBoolean(Session["__ISREFRESH"].ToString()));
}
protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] AllStates = new object[3];
AllStates[0] = base.SaveViewState();
AllStates[1] = !(_refreshState);
return AllStates;
}
step3) at a button code write down following:
if (!(_isRefresh))
{
writedown your button code
}