-
In desktop apps, when a user attempts to exit a window with unsaved changes, it is common practice to employ the window Unload event to question the user whether they meant to save their changes. I am looking for a reliable way to do this in Blazor when a user exits a window via the forward/back arrows or through breadcrumb navigation. Blazor does not seem to have a window Unload event available to C#. From my research, the unload event can be trapped either in a WinowOnUnload event available to JavaScript, or in a Dispose() function. Dispose has a drawback in that although it can kick off an asynchronous method, it does not wait for it to complete. I assume others have already addressed this, so I am looking for some guidance or an example. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind. Solved my own problem using the section "Handle/prevent location changes" in this doc: https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-7.0#handleprevent-location-changes |
Beta Was this translation helpful? Give feedback.
Never mind. Solved my own problem using the section "Handle/prevent location changes" in this doc: https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-7.0#handleprevent-location-changes