I have the following code and I don't know were is the mistake:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(factura fac)
{
if (fac.numar>0)
ModelState.AddModelError("numar", "Numar este invalid .");
if (fac.serie.Trim().Length == 0)
ModelState.AddModelError("serie", "Serie invalida");
if (!ModelState.IsValid) return View("Create", fac);
}
Here I try validate an textbox "serie" and I got the following error
Object reference not set to an instance of an object.
Thank you