Hai
in ur treeview expand and collapse page hit the server,so in page onbeforeunload event fires,so try to avoid page refresh when expand or collapse treeview,so use update panel for treeview,it avoid page reload,
U have to move confirm message to server side button click event instead of client side or use client side button click event dont use window event,
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
in treeview expand and collapse u did in server side ?,try to expand and collapse form client. side
regards
Aravind