C
C#3y ago
Eple

❔ problem with ModelState

I have a Razor Page with two forms:
<form method="post" asp-page-handler="CreateTemplate">
<input asp-for="Template.Name" />
</form>
<form method="post" asp-page-handler="CreateField">
<input asp-for="FieldInput.Name" />
</form>
<form method="post" asp-page-handler="CreateTemplate">
<input asp-for="Template.Name" />
</form>
<form method="post" asp-page-handler="CreateField">
<input asp-for="FieldInput.Name" />
</form>
Two BindProperties
[BindProperty]
public Template Template { get; set; } = default!;
[BindProperty]
public FieldInputModel FieldInput { get; set; } = default!;
[BindProperty]
public Template Template { get; set; } = default!;
[BindProperty]
public FieldInputModel FieldInput { get; set; } = default!;
In OnPostCreateTemplateAsync, ModelState.IsValid == false because it validates both forms, while I only want it validate the one form I submitted. How do I solve it?
1 Reply
Accord
Accord3y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?