asp.net mvc 模型验证注解,表单提交
2013-11-20 13:19
393 查看
一、添加模型
View Code
主意,该视图是使用mvc模板创建,也可以手动编写
@model MvcApplication2.Models.Account @{ ViewBag.Title = "Register"; } <h2>Register</h2> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>Account</legend> <div class="editor-label"> @Html.LabelFor(model => model.Name) </div> <div class="editor-field"> @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> <div class="editor-label"> @Html.LabelFor(model => model.Age) </div> <div class="editor-field"> @Html.EditorFor(model => model.Age) @Html.ValidationMessageFor(model => model.Age) </div> <div class="editor-label"> @Html.LabelFor(model => model.Height) </div> <div class="editor-field"> @Html.EditorFor(model => model.Height) @Html.ValidationMessageFor(model => model.Height) </div> <div class="editor-label"> @Html.LabelFor(model => model.Birthday) </div> <div class="editor-field"> @Html.EditorFor(model => model.Birthday) @Html.ValidationMessageFor(model => model.Birthday) </div> <div class="editor-label"> @Html.LabelFor(model => model.Phone) </div> <div class="editor-field"> @Html.EditorFor(model => model.Phone) @Html.ValidationMessageFor(model => model.Phone) </div> <div class="editor-label"> @Html.LabelFor(model => model.Address) </div> <div class="editor-field"> @Html.EditorFor(model => model.Address) @Html.ValidationMessageFor(model => model.Address) </div> <div class="editor-label"> @Html.LabelFor(model => model.Email) </div> <div class="editor-field"> @Html.EditorFor(model => model.Email) @Html.ValidationMessageFor(model => model.Email) </div> <div class="editor-label"> @Html.LabelFor(model => model.EmailConfirm) </div> <div class="editor-field"> @Html.EditorFor(model => model.EmailConfirm) @Html.ValidationMessageFor(model => model.EmailConfirm) </div> <div class="editor-label"> @Html.LabelFor(model => model.Password) </div> <div class="editor-field"> @Html.EditorFor(model => model.Password) @Html.ValidationMessageFor(model => model.Password) </div> <div class="editor-label"> @Html.LabelFor(model => model.email_B) </div> <div class="editor-field"> @Html.EditorFor(model => model.email_B) @Html.ValidationMessageFor(model => model.email_B) </div> <p> <input type="submit" value="Create" /> </p> </fieldset> }
View Code
主意,该视图是使用mvc模板创建,也可以手动编写
相关文章推荐
- ASP.NET MVC 基于强类型视图下 对模型以及模型中List 字段的同时编辑 表单提交
- ASP.NET MVC 客户端验证失败后表单仍然提交问题
- ASP.NET MVC 客户端验证失败后表单仍然提交问题
- Asp.net Mvc post表单提交多个实体模型
- ASP.NET MVC Framework体验(3):表单提交
- HTML5中custom data-*特性与asp.net mvc 3 表单验证
- ASP.NET MVC 3.0:基于Ajax的表单提交,A页面认证失败后页面被强转至登录页面,待登录成功将如何回到A页面?
- ASP.NET MVC 2博客系列之二:模型验证
- ASP.NET MVC 2 模型验证
- ASP.NET MVC post提交表单 后台值为空
- asp.net mvc利用Json验证数据和导向页面,解决重复提交问题
- ASP.NET MVC学习之模型验证篇
- ASP.NET MVC 表单提交
- ASP.NET MVC 2博客系列之二:模型验证
- ASP.NET MVC Framework体验(3):表单提交
- Asp.Net Mvc表单提交之List集合
- 【转】Scott_ASP.NET MVC框架(第四部分) 处理表单编辑和提交场景
- ASP.NET MVC 结合EDMX 数据模型验证
- ASP.NET MVC 第五个预览版和表单提交场景