Implementation of the registration page
1. based on the HTML Helper Makeover registration page that was introduced last view--register.cshtml
1) You need to add a strongly typed declaration at the top of the view
@model MVCDemo.Models.Account
2) Change Form label
<form class= "Form-horizontal" > </form>
Switch
@using (Html.BeginForm ("Register", "Account", FormMethod.Post, new {@class = "form-horizontal"}))
{ }
3) Retrofit Lanel and input
Reference:http://blog.csdn.net/pasic/article/details/7093802
<label for= "InputEmail3" class= "col-sm-2 control-label" > Email </label>
Switch
@Html. labelfor (model = model. email,new {@class = "col-sm-2 Control-label"})
<input type= "Email" class= "Form-control" id= "inputEmail3" placeholder= "Enter Mailbox" >
Switch
@Html. textboxfor (model = model. Email, new {@class = "Form-control"})
<label for= "InputPassword3" class= "col-sm-2 Control-label" > Password </label>
Switch
@Html. labelfor (model = model. PassWord)
<input type= "Password" class= "Form-control" id= "InputPassword3" placeholder= "Enter password" >
Switch
@Html. passwordfor (model = model. PassWord, new {@class = "Form-control"})
Address Reconstruction method with mailbox
The password is as follows:
2. Add a new [Httppost]register method under AccountController
3. Increase client authentication, two passwords are consistent
1) Modify Form Properties
Add Form Property
@using (Html.BeginForm ("Register", "Account", FormMethod.Post, new {@class = "form-horizontal", @onsubmit = "return IsValid () "}))
Add form Submission Validation attribute: @onsubmit = "return IsValid ()"
2) Create JavaScript validation files
Under the script file, create a new JavaScript file named "Validations.js"
3) Create a validation function
Create a validation function in the "validations.js" file:
4) Add validations.js file reference in View:
@section headersection{
@* Note: The code here to introduce JS CSS does not omit this section *@
<link href= "~/content/site.css" rel= "stylesheet"/>
<script src= "~/scripts/jquery-1.10.2.min.js" ></script>
<script src= "~/scripts/validations.js" ></script>
}
MVC Series-6. Registration page