mvc 客户端验证

@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>

mvc 客户端验证,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。