MVC2の検証の概要と必要なメタデータ
-
19-09-2019 - |
質問
ソースコードに...
私はこのような流暢modelmetadataプロバイダを使用して必要なメタデータを指定する場合は、シングは、ある=>
public class Foo
{
public string Bar { get; set; }
}
public class FooModelMetadataConfiguration : ModelMetadataConfiguration<Foo>
{
public FooModelMetadataConfiguration()
{
Configure(x => x.Bar)
.Required("lapsa") ;
}
}
そして、私のビューにこれを書く=>
<% Html.BeginForm(); %>
<%= Html.ValidationSummary() %>
<%= Html.TextBoxFor(x=>x.Bar) %>
<% Html.EndForm(); %>
そして、ホームコントローラにこれを追加=>
[HttpPost]
public ActionResult Index(Foo foo)
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
return View(foo);
}
これが出力されます。このHTML =>
<div class="validation-summary-errors">
<ul>
<li>lapsa</li>
<li>The Bar field is required.</li>
</ul>
</div>
2回目のエラーがレンダリングされると、それを省略するか、なぜ私は理解できないことができます。
System.Web.Mvc.Extensibilityフレームワークの作者は=>
と答え私は、私はそれを読んでいる正確な場所を覚えていない可能性があり、これはasp.netのMVCの既知の問題だと思う、私はあなたがCodePlexのオーバーasp.net MVC課題追跡に問題を投稿して提案します。
しかし、私は、課題追跡に何かを投稿する前に - 私が間違っている正確に何を最初に理解したいと思います。
。それに任意のヘルプ?
解決
これは今に固定されます。
所属していません StackOverflow