Asp.Net Mvc 3 Client Validation, Attributes generation

后端 未结 2 1654
甜味超标
甜味超标 2021-02-14 18:41

Asp.net Mvc3 ads some custom attributes like \"data-val-required\" on input elements to perform validation. I know all theory behind this, how it works.

What i want to k

2条回答
  •  醉酒成梦
    2021-02-14 19:39

    Problem here is that internally Html.BeginForm is flagged by Html.EnableClientValidation() to create FormContext that will store client-side validation metadata. Now, any HTML helper method that renders validation message also registers appropriate client-side validation metadata in FormContext. The result is what you get if you use helper. However, if you try to use HTML syntax and not helpers, the FormContext is never registered and therefore your validation is never added.

    Regards,

    Huske

提交回复
热议问题