MVC Series-6. Registration page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.