ASP.NET MVC 3: Generate unobtrusive validation when BeginForm is on the layout

前端 未结 5 1626
一个人的身影
一个人的身影 2020-12-09 13:31

I just realized that when I place a form tag on my layout page, surrounding the RenderBody section, the unobtrusive validation is not being generated. Something like this:

5条回答
  •  情深已故
    2020-12-09 13:59

    Just add below code at top of the child view file...

    @{
       Layout = "~/Views/Shared/_Layout.cshtml";
       this.ViewContext.FormContext = new FormContext();
    }
    

    its working fine for me.

    i hope this will help you....

提交回复
热议问题