I want to be able to render a form with Blazor (Server Side Rendering) but I am not getting the right syntax.
<EditForm Model="@Model" OnValidSubmit="@SubmitValidForm">
<FluentValidationValidator />
<ValidationSummary />
<p class="name">
Name: <InputText bind-Value="@Model.Name" placeholder="Name"/>
</p>
<button type="submit">Submit</button>
</EditForm>
@code {
Person Model = new Person();
void SubmitValidForm()
{
Console.WriteLine("OnValidSubmit");
}
}
and
public class Person : ComponentBase
{
[Required(ErrorMessage = "Enter a name")]
[StringLength(10, ErrorMessage = "That name is too long")]
public string Name { get; set; } = "asd";
[Range(0, 200, ErrorMessage = "Nobody is that old")]
public int AgeInYears { get; set; }
[Required]
[Range(typeof(bool), "true", "true", ErrorMessage = "Must accept terms")]
public bool AcceptsTerms { get; set; }
}
But I get this error
Microsoft.AspNetCore.Components.Forms.InputText requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'.
How does one render the page and do a simple post to the server?