@model MvcApplication1.Models.ViewClass
@{
ViewBag.Title =
"View2";
}
@******引用这两个js实现客户端的验证 ********@
<script
src="../../Scripts/jquery.validate.min.js"
type="text/javascript"></script>
<script
src="../../Scripts/jquery.validate.unobtrusive.min.js"
type="text/javascript"></script>
<hr />
viewdata无法跨控制传值
ViewData:
@ViewData["View1"]
<hr
/>
TempData可以跨一次控制进行传值
@TempData["View3"]
<h2>View2</h2>
<div >
@Html.ValidationSummary(true)
@using
(@Html.BeginForm())
{
<div >
@Html.LabelFor(m=>m
.Name)
@Html.EditorFor(m=>m.Name)
@Html.ValidationMessageFor(m=>m .Name)
</div>
<div >
@Html.LabelFor(m=>m.Age)
@Html.EditorFor(m=>m .Age)
@Html.ValidationMessageFor(m=>m
.Age)
</div>
<div >
@Html.LabelFor(m=>m .Address)
@Html.EditorFor(m=>m .Address)
@Html.ValidationMessageFor(m=>m .Address)
</div>
<input type ="submit" value="提交" />
<div >
<span></span>
</div>
}
</div>