This question is locked. New answers and comments are not allowed.
Hi there - not sure if I'm making a repeat post as I got a server error when I made it the last time.. apologies if so
Anyhow here goes again. I am trying to use client side validation, but do it in a custom manner. By this I mean check some stuff in the save action and validate by e.g. adding to the ViewData.ModelState. This is because the property being validated is a string and the format depends on external factors so Data Annotations don't work. e.g. something like this pseudo code:
| [GridAction] |
| public ActionResult _SaveAnObjectByAjax(int ID, int ObjectTypeID, string TextValue) |
| { |
| var ObjectType = rep.GetObjectType(ObjectTypeID); |
| var regex = new Regex(ObjectType.ValidationExpressionString); |
| if (!regex.IsMatch(TextValue)) |
| ViewData.ModelState.AddModelError("TextValue", "That sucks! Try something like " + ObjectType.ExampleString); |
| Return(new GridModel(rep.All()))} |
Not too optimistic as I can't see how it would fit with your jquery validation but hey I'm new to this MVC stuff and would be great if you guys had any suggestions. Excellent extensions by the way.