0
votes

I have an unload event in my page which does not fire when i'm navigating to the next page? is there any option to invoke this event explicitly before navigating to the next page? I have tried "window.onbeforeunload" but it is displaying a prompt with a message before leaving the current page. I do not want to display the prompt? is there any possibilities to achieve this?

[ASPX]

<asp:TreeView ID="TreeView1" runat="server" OnUnload="TreeView_Unload">
<Nodes>
<asp:TreeNode Text="Node1" NavigateUrl="http://www.google.com"></asp:TreeNode>
</Nodes>
</asp:TreeView>

[C#] protected void TreeView_Unload(object sender, EventArgs e) {

}
1

1 Answers

0
votes

How are you directing the user to the next page?

If you are using Response.Redirect(URL, True) then the response would end at that point and page processing would not be completed (at least, I don't think the unload events would fire). If you are forcing immediate redirection, then you could try changing your redirect to Response.Redirect(URL, False) instead, this would allow your code to finish processing and then redirect the user once completed.