Hi, I am moving 1 project, just the data tier, the project is using MVC 1.0 and acess mdb :S
Now I am moving to SubSonic + Sql server and all is fine, except when I try to implement to my class IDataErrorInfo for validation messages, I get always 2 times every error message
I have a table class generated by subsonic:MyTable, then I extend it.
public partial class myTable : IDataErrorInfo{
public string this[string columnName]{
get{
switch (columnName.ToUpperInvariant()){
case "MYFIELD":
if (string.IsNullOrEmpty(myField)){
return "Incorrect MyField";
}
break;
case "ANOTHER":
if (string.IsNullOrEmpty(myField)){
return "Incorrect Another";
}
break;
}
return "";
}
}
public string Error{
get{
return "";
}
}
}
In My Controller I add to my post action this code:
public class mycontroller...{
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult myAction(int id, MyTable data)
{
try
{
UpdateModel(data, new[] { "MyField","Another" });
data.Save();
return RedirectToAction("Admin");
}
catch (Exception ex)
{
//ViewData["Error"] = ex.Message;
return View(data);
}
}
My view have a summary generated as Html.ValidationSummary("Attention:")
When I get invalid data My summary get 2 times the error as it:
Attention:
Incorrect MyField
Incorrect MyField
Incorrect Another
Incorrect Another
I don't want to rewrite the validation form, here is a lot of views (about 130). I think the problem is in some place in subsonic, but I can't get where :S, Please help me :)
Best regards and thanks in advance.
no way to catch this error :(