Generating jquery 'rules' from business model to UI in asp.net mvc
Posted
by jim
on Stack Overflow
See other posts from Stack Overflow
or by jim
Published on 2010-04-06T20:54:23Z
Indexed on
2010/04/06
21:03 UTC
Read the original article
Hit count: 225
asp.net-mvc
|jQuery
Hi all,
I've had a good look around and am certain that there's no matching question on SO, so here goes.
Has anyone created a 'helper' method on their model that generates jquery (or plain javascript) rules validation dynamically, based on the criteria/rules that are contained within the object and taken from a repository (i.e. DB).
What i'm thinking of is a discrete set of partial views (and associated models) that have rules at the business logic 'level' and rather than (or in combination with) validating the rule(s) at postback, translating the same rules into tightly focussed jquery methods that work identically at client (js) and server (c#) levels. I can see benefits here re performance. Also, the rules definitions could be created in a single place (in c#) and the jquery generated off of that, thus allowing single edits to update both code streams.
I appreciate that there would be limitations imposed by language specific contstraints but the general principle could be quite interesting if used appropriately. I'm also aware that testibility could be an issue when using two different language structures and hoping to achieve similar test outcomes - but those aside...
any thoughts or experiences of similar out there??
cheers jimi
© Stack Overflow or respective owner