ASP.NET MVC 3 unobtrusive client-side validation with dynamic content

前端 未结 2 1197
星月不相逢
星月不相逢 2021-01-22 14:45

I have enabled unobtrusive client side validation in my app, and I have (something similar) to this model:

public class MyModel
{
    [Required]
    public strin         


        
2条回答
  •  星月不相逢
    2021-01-22 15:16

    You dont need the form in your partial (theres an advantage at times to keeping it out, for ex. ajax forms and not having to rebind to a new form upon each load).

    In your partial simply add

    { ViewContext.FormContext = new FormContext()} 
    

    and the attributes will be written out.

提交回复
热议问题