I've been having some trouble clearing server variables during unload events of pages using RadAjaxManager.
If I click on a link which navigates away from the page, I need to clear a session variable before continuing.
TestPage.aspx page:
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="OnAjaxRequest" />
....
<a href="google.com">google!</a>
...
<telerik:RadScriptBlock runat="server">
<script type="text/javascript">
function onunload(sender, args) {
var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
ajaxManager.ajaxRequest("pageUnload");
}
Sys.Application.add_unload(onunload);
</script>
</telerik:RadScriptBlock>
protected void OnAjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "pageUnload")
{
Session["someSessionVar"] = null;
}
Unfortunately this does not work. After the OnAjaxRequest event, the browser remains on the TestPage.aspx. It does not continue navigating to the original link clicked (google.com). {
Session["someSessionVar"] = null;
}
}
How can I set a server variable when a page is navigated away from?
Thanks,
Josh