T
tshad
I got a piece of code to check if a Web page was refreshed (user pressed
refresh button).
But I can't get it to work.
The code is:
************************************************************
namespace StevenBey.Web.UI
{
public class Page : 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;
}
}
}
************************************************************
If I do a:
trace.warn("is Refresh = " & Page.IsRefresh)
or
trace.warn("is Refresh = " & IsRefresh)
I get the error:
BC30456 'IsRefresh' is not a member of 'System.Web.UI.Page'
I took the compiled version (StevenBey.Web.UI.dll) and put it in my Bin
directory.
If you look at trace page you won't see __ISREFRESH?
Is there something else I need to do to get this to work?
Thanks,
Tom
refresh button).
But I can't get it to work.
The code is:
************************************************************
namespace StevenBey.Web.UI
{
public class Page : 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;
}
}
}
************************************************************
If I do a:
trace.warn("is Refresh = " & Page.IsRefresh)
or
trace.warn("is Refresh = " & IsRefresh)
I get the error:
BC30456 'IsRefresh' is not a member of 'System.Web.UI.Page'
I took the compiled version (StevenBey.Web.UI.dll) and put it in my Bin
directory.
If you look at trace page you won't see __ISREFRESH?
Is there something else I need to do to get this to work?
Thanks,
Tom