小编use*_*036的帖子

必需属性在asp.net mvc中不起作用

我有一个简单的强类型视图.

@model GoldForGold.Models.LogonModel
@{
    ViewBag.Title = "Logins";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Logins
@using (Html.BeginForm()) {

Account Information
@Html.LabelFor(m => m.UserName)
@Html.TextBoxFor(m => m.UserName, new { id = "txtUserName" })
@Html.ValidationMessageFor(m => m.UserName)
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password, new { id = "txtPassword" })
@Html.ValidationMessageFor(m => m.Password)
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)

<input type="submit" value="Log On" onclick="getcredentials()" />
}
Run Code Online (Sandbox Code Playgroud)

型号代码在这里.

public class LogonModel
{
    [Required(ErrorMessage="please enter username")]
    [Display(Name = "User name")]
    public string UserName { get; set; }

    [Required] …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-viewmodel

1
推荐指数
4
解决办法
2万
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-viewmodel ×1