ASP.NET MVC DisplayName未显示
我添加了显示名称,但是运行应用程序时没有显示。
员工.cs
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
[Required]
[DisplayName("First Name & Last Name")]
public string FullName { get; set; }
addemployee.cshtml
@model employee_creation.Models.Employee
@{
ViewData["Title"] = "Add Employee";
}
<label asp-for="FullName" class="form-label font-w600"></label>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 docs 看起来您应该使用
[display> =“ name =”名字&amp; last名称“)]
。在许多情况下,这些属性的起作用相同,但我们需要记住,这是两种不同的类型 - 我想标签助手不支持两者
Based on docs it looks like you should use
[Display(Name = "First Name & Last Name")]
instead.In many scenarios these attributes works the same but we need to remember that those are two different types - and I guess Tag helpers does not support both
将始终显示“ 名字&amp;姓”。要在标签中获得实际值,请使用下面的代码IE
will always show "First Name & Last Name". To get the actual value inside label use below code i.e.