Художники, не стреляющие на странице бритвы при открытии с помощью диалогового сервиса ⇐ C#

Место общения программистов C#
Anonymous
Художники, не стреляющие на странице бритвы при открытии с помощью диалогового сервиса

Сообщение Anonymous »

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):
LocationChangingHandler
OnBeforeInternalNavigation, nor
EditContextOnFieldChanged
in .razor: < /p>

Код: Выделить всё

@implements IDisposable



//form fields in here


< /code>
`< /p>
in .razor.cs: < /p>
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;
}
}
Любая помощь будет высоко оценена!

Подробнее здесь: https://stackoverflow.com/questions/796 ... og-service

Вернуться в «C#»