我希望能够使用Blazor (服务器端渲染)呈现表单
我尝试了大部分的教程,但我看不出我做错了什么。我将.net核心更新到最新版本SDK3.0.100-preview6-012264
<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");
}
}
和
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; }
}
但我得到了
'Microsoft.AspNetCore.Components.Forms.InputText requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'.'
我想呈现页面并向服务器发送一个简单的post
有人能帮帮忙吗?
https://stackoverflow.com/questions/57027047
复制相似问题