I want to show an error if data load fails in OnInitializedAsync. I will save the message in a variable and show it in OnAfterRenderAsync or OnAfterRender.
The toast work when the page is fully loaded and I press the button
I am very open for suggestion on showing messages in another way
I have tried all the life cycle handler but in theory this should work.
The toast work when the page is fully loaded and I press the button
I am very open for suggestion on showing messages in another way
I have tried all the life cycle handler but in theory this should work.
public partial class TelerikTest
{
[Inject] public IJSRuntime JsRuntime { get; set; }
[Inject] public NavigationManager Navigation { get; set; }
private TelerikNotification NotificationReference { get; set; }
protected override void OnAfterRender(bool firstRender)
{
if (firstRender && Navigation.Uri.StartsWith("https"))
{
StateHasChanged();
ShowErrorNotification();
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && Navigation.Uri.StartsWith("https"))
{
await JsRuntime.InvokeVoidAsync("console.log", "Component rendered!");
StateHasChanged();
}
}
private void ShowErrorNotification()
{
NotificationReference.Show(new NotificationModel
{
Text = "An error has occurred!",
ThemeColor = ThemeConstants.Notification.ThemeColor.Error,
Closable = true,
CloseAfter = 20000
});
}
}
I ended up using the modal TelerikWindow