About a Question

This is 👍
public class RegisterViewModel
{
[Required]
[DataType(DataType.EmailAddress)]
[StringLength(30, ErrorMessage = “The {0} must be at least {2} and at max {1} characters long.”, MinimumLength = 8)]
[Display(Name =”邮箱:”)]
public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "密码:")]
    public string Pwd { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "再次输入密码:")]
    [Compare("Pwd", ErrorMessage = "两次输入的密码不匹配.")]
    public string ConfirmPwd { get; set; }
}

Next:This is my View.cshtml************************************************
****
@model RegisterViewModel
@{
ViewData[“Title”] = “Register”;
}

<h2>@viewdata[“Title”]

<div class=”row”>
<div class=”col-md-4″>
<form asp-route-returnUrl=”Account/Register2″ method=”post”>
<h4>Create a new account.
<hr />
<div asp-validation-summary=”All” class=”text-danger”>
<div class=”form-group”>
<label asp-for=”Email”>
<input asp-for=”Email” class=”form-control” />
<span asp-validation-for=”Email” class=”text-danger”>
</div>
<div class=”form-group”>
<label asp-for=”Pwd”>
<input asp-for=”Pwd” class=”form-control” />
<span asp-validation-for=”Pwd” class=”text-danger”>
</div>
<div class=”form-group”>
<label asp-for=”ConfirmPwd”>
<input asp-for=”ConfirmPwd” class=”form-control” />
<span asp-validation-for=”ConfirmPwd” class=”text-danger”>
</div>
<button type=”submit” class=”btn btn-default”>Register
</form>
</div>
</div>

@section Scripts {
@await Html.PartialAsync(“_ValidationScriptsPartial”)
} `
Question:*******************
Eventhrouth I submit my form data, It also remind me a danger: User Name must be letters or digilts….
But I have No named “UserName” INPUT….


Author: Fantashit

1 thought on “About a Question

Comments are closed.