NCCSBIM071
NCCSBIM071

Reputation: 1205

Dynamic view page with jQuery unobtrusive validation in asp.net mvc3

I have been developing an asp.net mvc3 application.

Here is my situation: The controls that are supposed to be displayed in the view page is in database. In database we have stored all the control definitions, for example control type, validation regex, required or not. Currently what i am doing is, i am retrieving the records for controls and using html helpers to build the form elements and displaying the view page.

The problem with this approach is that, i can't use jQuery unobtrusive validation.

Is it possible to have a dynamic model to which i can add properties and data annotation at runtime and display the view page. doing this way i will have a page which can support jQuery unobtrusive validation.

or

please suggest any other alternative solution.

Upvotes: 0

Views: 431

Answers (1)

Matija Grcic
Matija Grcic

Reputation: 13381

Maybe you can check this: https://stackoverflow.com/a/3609521/1241400 or call $.validate.unobtrusive.parse("#selector") after you load the form. and for dynamically building a model check this great post: http://romiller.com/2012/03/26/dynamically-building-a-model-with-code-first/

Regards

Upvotes: 1

Related Questions