다음 모델을 고려하여 내보기에 올바른 DsiplayName을 어떻게 표시합니까?DisplayName 메타 데이터가보기에 표시되지 않습니다.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Project.Models.RegisterViewModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm())
{%>
<table>
<tr>
<td class="label">
<%: Html.LabelFor(model => model.User.UserPrimaryEmail)%>
</td>
<td class="field">
<%: Html.TextBoxFor(model => model.User.UserPrimaryEmail)%>
</td>
<td class="field-error">
<div class="field-error-msg">
<%: Html.ValidationMessageFor(model => model.User.UserPrimaryEmail)%>
</div>
</td>
</tr>
</table>
</asp:Content>
public class RegisterViewModel
{
public User User { get; set; }
}
[MetadataType(typeof(UserMetaData))]
public partial class User : UserBase
{
//Inherits from Generated Class UserBase
//to set default values here for the constructor
// Not used except as a source of metadata
public class UserMetaData
{
[Required]
[DisplayName("Email Login")]
[DataType(DataType.EmailAddress)]
[Email(ErrorMessage = "Invalid Email")]
public string UserPrimaryEmail { get; set; }
}
}
양식 그러나 당신은 당신의 데이터 주석을 추가하고, "이메일 로그인"하지만 "UserPrimaryEmail"
가능한 중복 http://stackoverflow.com/questions/4456860/displayname-metadata-does-not-show -up-on-view) – SLaks
내 인터넷 연결이 오래 전에 느 렸습니다. 다른쪽에 깃발을 꽂아주세요. 이거 말고. –