I have created a simple form which can be filled out and saved to the database but I don't know how I can implement any kind of success message in a blazor component. This is my form:
<EditForm Model=@Input OnValidSubmit="Speichern">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-row">
<div class="form-group col-md-6">
<label>Vorname</label>
<InputText class="form-control" @bind-Value="Input.FirstName" />
<ValidationMessage For="() => Input.FirstName" />
</div>
<div class="form-group col-md-6">
<label>Nachname</label>
<InputText class="form-control" @bind-Value="Input.LastName" />
<ValidationMessage For="() => Input.LastName" />
</div>
</div>
<div class="form-group">
<label>Username</label>
<InputText class="form-control" @bind-Value="Input.Username" />
<ValidationMessage For="() => Input.Username" />
</div>
<div class="form-group">
<label>E-Mail</label>
<InputText class="form-control" @bind-Value="Input.Email" />
<ValidationMessage For="() => Input.Email" />
</div>
<div class="form-group">
<label>Telefonnummer</label>
<InputText class="form-control" @bind-Value="Input.PhoneNumber" />
<ValidationMessage For="() => Input.PhoneNumber" />
</div>
<button type="submit" class="btn btn-primary">Speichern</button>
</EditForm>
The method Speichern() saves the changes to the SQL-Database
public async void Speichern()
{
Mitarbeiter.UserName = Input.Username;
Mitarbeiter.FirstName = Input.FirstName;
Mitarbeiter.LastName = Input.LastName;
Mitarbeiter.Email = Input.Email;
Mitarbeiter.PhoneNumber = Input.PhoneNumber;
Mitarbeiter.EmailConfirmed = true;
await UserManager.UpdateAsync(Mitarbeiter);
}
After the await statement I want to set a custom message. I know I can do it with a string property and set it to any kind of text but I want to be more flexible here. Is it possible to even display a custom component? Perhaps with a custom Alert component?