日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

MVC系列-6.注册页面

發布時間:2024/9/5 c/c++ 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MVC系列-6.注册页面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

注冊頁面的實現

1.根據上回所介紹的Html Helper改造注冊頁view--Register.cshtml

1)在View的頂部需要添加一個強類型聲明

@model MVCDemo.Models.Account

2)改造表單form標簽

<form class="form-horizontal"> </form>

改為

@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class="form-horizontal"}))

??????? {??? }

3)改造lanel和input

參考資料:http://blog.csdn.net/pasic/article/details/7093802

<label for="inputEmail3" class="col-sm-2 control-label">郵箱</label>

改為

@Html.LabelFor(model => model.Email,new { @class = "col-sm-2 control-label" })

<input type="email" class="form-control" id="inputEmail3" placeholder="輸入郵箱">

改為

@Html.TextBoxFor(model => model.Email, new { @class = "form-control" })

<label for="inputPassword3" class="col-sm-2 control-label">密碼</label>

改為

@Html.LabelFor(model => model.PassWord)

<input type="password" class="form-control" id="inputPassword3" placeholder="輸入密碼">

改為

@Html.PasswordFor(model => model.PassWord, new { @class ="form-control" })

地址改造方法同郵箱

代密碼如下:

2.AccountController下新增一個[HttpPost]Register方法

3.增加客戶端驗證,兩次密碼是否一致

1)修改表單屬性

增加form屬性

@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class="form-horizontal",@onsubmit = "return IsValid()" }))

增加表單提交驗證屬性:@onsubmit = "return IsValid()"

2) 創建JavaScript 驗證文件

在Script文件下,新建JavaScript文件,命名為“Validations.js”

3) 創建驗證函數

在“Validations.js”文件中創建驗證函數:

4)View 中添加 Validations.js文件引用:

@section HeaderSection{

@*注釋:這里放引入js css的代碼? 沒有可省略本部分*@

<link href="~/Content/Site.css" rel="stylesheet" />

<script src="~/Scripts/jquery-1.10.2.min.js"></script>

<script src="~/Scripts/Validations.js"></script>

}

轉載于:https://www.cnblogs.com/lingr/p/5563463.html

總結

以上是生活随笔為你收集整理的MVC系列-6.注册页面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。