I'm in the process of upgrading an ASP.NET WebForms application to ASP.NET MVC. One of the features on the existing application is it has a dynamic form generator. Each form has steps (using the wizard control that are dynamically added in the Wizard_Init event) and validation (using the validation controls).
I already have some static MVC forms where I use data annotation attributes on my model properties and then use the in-built unobtrusive validation to validate the form.
Now say I have the following model:
public class Form {
public string Name { get; set; }
public IList<Step> Steps { get; set; }
}
public class Step {
public string Name { get; set; }
public IList<Field> Fields { get; set; }
}
public class Field {
public string Name { get; set; }
public bool IsRequired { get; set; }
}
Obviously the fields are dynamic so I can't use the data annotation attributes. Also I only wish to validate each step. One option I thought was to render all the steps within the form and show/hide the appropriate step using javascript as they click next/previous. But again I can't see how I can add validation to this. Another option is to load in each step using Ajax but again I'm struggling with this concept.
I'd really appreciate it if someone could help. Ideally I'd like advice on the best way to achieve this rather than linking to an old third party library unless it has been built since ASP.NET MVC 3. Thanks