Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Handlers not firing in razor page when opened via dialog service

$
0
0

None of the following Events/Handlers are firing in razor pages opened via the radzen dialogservice using openasync (they work when not opened in a dialog):

LocationChangingHandlerOnBeforeInternalNavigation, norEditContextOnFieldChanged

in .razor:

@implements IDisposable<RadzenTemplateForm id="ConferenceCityForm" EditContext="Context" TItem="ConferenceCityVm" Data=ConferenceCity Submit=@OnValidSubmit InvalidSubmit=@OnInvalidSubmit>//form fields in here</RadzenTemplateForm>

`

in .razor.cs:

private bool IsDirty { get; set; } = false;private IDisposable Registration { get; set; } = default!;private EditContext Context { get; set; } = default!;protected override async Task OnInitializedAsync(){  Context = new EditContext(ConferenceCity);  Context.OnFieldChanged += EditContextOnFieldChanged;  await base.OnInitializedAsync();}protected override Task OnAfterRenderAsync(bool isFirstRender){  if (isFirstRender == true)     Registration = NavigationManager.RegisterLocationChangingHandler(LocationChangingHandler);  return base.OnAfterRenderAsync(isFirstRender);}private async Task OnBeforeInternalNavigation(LocationChangingContext locationChangingContext){  if (IsDirty == true)  {     var returnValue = await DialogService.Confirm("Are you sure you want to lose unsaved changes?");    if (returnValue == false)        locationChangingContext.PreventNavigation();    else        IsDirty = false;  }}private async ValueTask LocationChangingHandler(LocationChangingContext arg){    if (IsDirty == true)    {        var returnValue = await DialogService.Confirm("Are you sure you want to lose unsaved changes?");        if (returnValue == false)            arg.PreventNavigation();        else            IsDirty = false;    }}

Any help would be greatly appreciated!


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>