首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >InputText需要'ValueExpression‘参数的值

InputText需要'ValueExpression‘参数的值
EN

Stack Overflow用户
提问于 2019-07-14 19:34:01
回答 4查看 9.4K关注 0票数 22

我希望能够使用Blazor (服务器端渲染)呈现表单

我尝试了大部分的教程,但我看不出我做错了什么。我将.net核心更新到最新版本SDK3.0.100-preview6-012264

代码语言:javascript
复制
    <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");
    }
}

代码语言:javascript
复制
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; }
    }

但我得到了

代码语言:javascript
复制
'Microsoft.AspNetCore.Components.Forms.InputText requires a value for the 'ValueExpression' parameter. Normally this is provided automatically when using 'bind-Value'.'

我想呈现页面并向服务器发送一个简单的post

有人能帮帮忙吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57027047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档