I have a blazor page with the below markup. I am trying to add custom validation to it, which requires the EditContext.
My page (abbrievated) is as below:
<AuthorizeView>
<Authorized Context="Auth">
@if (_part == null)
{
<div>Loading...</div>
}
else
{
<EditForm Model="@_part" OnValidSubmit="@HandleValidSubmit">
....
</EditForm>
I have in my "code":
[CascadingParameter]
private EditContext EditContext { get; set; }
[CascadingParameter]
private EditForm EditForm { get; set; }
And ...
protected override void OnParametersSet()
{
base.OnParametersSet();
Debugger.Break();
if (this.EditContext != null)
{
this.FieldIdentifier = this.EditContext.Field("Sku");
}
else
{
if (this.EditForm != null)
{
this.EditContext = this.EditForm.EditContext;
}
}
}
In OnParametersSet, EditContext and EditForm are always null. Everything else seems to be fine. How could they be null?