布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- Apple devices fullscreen -->
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>New Indus Goods - Loagin</title>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/css/bootstrap.min.css")"/>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/css/plugins/icheck/all.css")"/>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/css/style.css")"/>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/css/themes.css")"/>
<link href="@Url.Content("~/Styles/view_specific_style.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("~/js/jquery.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/plugins/nicescroll/jquery.nicescroll.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/plugins/validation/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/plugins/validation/additional-methods.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/plugins/icheck/jquery.icheck.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/bootstrap.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/js/eakroko.js")"></script>
<!--[if lte IE 9]>
<script type="text/javascript" src="@Url.Content("~/js/plugins/placeholder/jquery.placeholder.min.js")"></script>
<script>
$(document).ready(function() {
$('input, textarea').placeholder();
});
</script>
<![endif]-->
<!-- Favicon -->
<link rel="shortcut icon" href="~/img/favicon.ico" />
<!-- Apple devices Homescreen icon -->
<link rel="apple-touch-icon-precomposed" href="~/img/apple-touch-icon-precomposed.png" />
</head>
<body class='login'>
<div class="wrapper">
<h1>
<a href="index.html">
<img src="@Url.Content("~/img/logo-big.png")" alt="" class='retina-ready' width="59" height="49">New Indus Goods</a>
</h1>
<div id="body" class="login-body">
@RenderSection("featured",required:false)
<section class="content-wrapper">
@RenderBody()
</section>
</div>
</div>
</body>
</html>
查看
@model Test1.Models.UserProfile
@{
Layout = "~/Views/_LayoutPage1.cshtml";
ViewBag.Title = "Index";
Test1.Models.UserProfile lol = ViewBag.Profile;
}
@section featured
{
@using (Html.BeginForm("Index", "Input"))
{
@Html.ValidationSummary(true)
<fieldset>
<div class="content-wrapper">
<div class="form-group">
<div class="email controls">
@Html.EditorFor(model => model.Name, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
</div>
<p>lol what is is</p>
</fieldset>
<p>
<input type="submit" value="Save" />
</p>
}
}
<div>
@Html.ActionLink("Back To Index", "Index");
</div>
执行服务器端验证,但客户端没有发生!请告诉我,我在这里失踪了什么?我曾尝试在Google上找到解决方案,但失败了。我是MVC的新手,所以请帮助我!页面返回POST然后返回并说需要名称字段,为什么在POSTING BACK之前没有验证?
答案 0 :(得分:0)
我必须添加
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
在页面相关的web.config中也是如此:)