[英]Mvc2 validation summary and required metadata
source code ... 源代码 ...
Thing is, if i specify required metadata using fluent modelmetadata provider like this=> 问题是,如果我使用像这样的流利的模型元数据提供程序指定所需的元数据,=>
public class Foo
{
public string Bar { get; set; }
}
public class FooModelMetadataConfiguration : ModelMetadataConfiguration<Foo>
{
public FooModelMetadataConfiguration()
{
Configure(x => x.Bar)
.Required("lapsa") ;
}
}
And write this into my view => 并将其写入我的视图=>
<% Html.BeginForm(); %>
<%= Html.ValidationSummary() %>
<%= Html.TextBoxFor(x=>x.Bar) %>
<% Html.EndForm(); %>
And add this to home controller => 并将其添加到家庭控制器=>
[HttpPost]
public ActionResult Index(Foo foo)
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
return View(foo);
}
It will output this html => 它将输出此html =>
<div class="validation-summary-errors">
<ul>
<li>lapsa</li>
<li>The Bar field is required.</li>
</ul>
</div>
I can't understand why 2nd error is rendered and how to omit it. 我不明白为什么会出现第二个错误以及如何忽略它。
Author of System.Web.Mvc.Extensibility framework replied with => System.Web.Mvc.Extensibility框架的作者回复为=>
I think this is a known issue of asp.net mvc, i could not remember the exact location where I have read it, I suggest you post the issue in asp.net mvc issue tracker over codeplex.
我认为这是asp.net mvc的已知问题,我不记得我阅读过的确切位置,建议您通过Codeplex将问题发布在asp.net mvc问题跟踪器中。
But before i post anything on issue tracker - i would like to understand first what exactly is wrong. 但是,在我在问题跟踪器上发布任何内容之前,我想先了解一下到底是什么问题。
Any help with that? 有什么帮助吗?
现在已修复 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.