I can't get xVal validation to work with strongly typed viewmodels.
Every method in xVal seems to want a prefix which is not used when dealing with strongly typed viewmodels.
My view contains code similar to this:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ContactForm>" %>
<%= Html.TextBox("firstName", Model.FirstName) %>
And the following code goes in the controller:
try
{
var theModel = form.ToModel();
_contactRepository.Save(theModel);
}
catch (RulesException ex)
{
ex.AddModelStateErrors(ModelState, string.Empty); // Passing string.Empty for prefix, since I don't use prefixes.
}
return View(form);
However, the above code doesn't work. I've surely missed something, but don't know what. This is my first time using xVal.
Thankful for any help!