Asp.Net Mvc 3 Client Validation, Attributes generation

后端 未结 2 1647
甜味超标
甜味超标 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:17

    I believe BeginForm method internally assigns a formcontext object to viewCotnext's property FormContext. If you do not want to use plain html form tags you have to do it manually like

    <%
        this.ViewContext.FormContext = new FormContext();
    %>
    

    and in razor it would probably be

    @{
        this.ViewContext.FormContext = new FormContext();
    }
    

提交回复
热议问题