【发布时间】:2021-08-23 01:22:45
【问题描述】:
我已经尝试创建我的第一个 Blazor 表单,它似乎已经完成了。我遇到的问题是:创建私有命名空间时 - 我认为它在这里被称为命名空间:
private _ExampleForm _exampleForm = new();
Visual Studio 说“找不到命名空间 _ExampleForm(是 您缺少指令或程序集参考?)
完整的代码在这里,我几乎是从官方Blazor documentation复制过来的
@page "/opportunity"
@using Microsoft.AspNet.Identity.EntityFramework
@using Microsoft.AspNet.Identity
@using System.Security.Cryptography.X509Certificates
@using Microsoft.Extensions.Logging
<EditForm Model="@_exampleForm" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText id="name" @bind-Value="_exampleForm.Name" />
<button type="submit">Submit</button>
</EditForm>
@code {
private _ExampleForm _exampleForm = new(); //PROBLEM LINE
private void HandleValidSubmit()
{
// do something
}
}
我在 Visual Studio 中使用带有自动 C# 版本检测功能的 .NET CORE 3.0。
【问题讨论】:
-
嗨@MattHodson,在文档中是
ExampleModel而不是_ExampleForm。你配置_ExampleForm模型了吗?
标签: asp.net-core blazor blazor-server-side