I am brand new to the world of .NET development, currently immersing myself in an ASP application with web forms. One particular page in the application contains a table. When a user clicks on a row within this table, it triggers the opening of a new tab. This newly opened tab displays a form with data already pre-filled from the selected row. To achieve this functionality, I utilized sessionStorage.
Now, my next challenge involves writing JavaScript that will remove the specific item from sessionStorage for both tabs when only the form tab is closed. Despite my efforts, whenever I close the form tab and inspect sessionStorage in the table tab, the property remains present. Any advice or suggestions would be greatly appreciated!
The code snippet below executes in the content footer section of the .aspx file alongside my other functional JavaScript scripts:
<asp:Content ID="Content3" ContentPlaceHolderID="contentfooter" runat="server">
<script>
window.addEventListener('unload', (e) => {
sessionStorage.removeItem('rowDataJSON');
});
</script>
</asp:Content>