我想在选定的列表中标注EF模型的人名和姓氏.我试过这个:
public ActionResult Insert()
{
ViewData["accountlist"] = new SelectList(time.Anagrafica_Dipendente.ToList(), "ID_Dipendente", "Surname Name", null);
Giustificativi g = new Giustificativi();
return View(g);
}
Run Code Online (Sandbox Code Playgroud)
但VS返回错误,因为没有名为"姓氏名称"的属性.如何在选择列表标签中连接姓名和姓氏?
谢谢
有没有办法根据MVC 3.0远程验证中的逻辑设置不同的错误
public ActionResult IsUserEmailExists(string email)
{
bool isExists = service.IsUserExists(email);
if(isExists )
//Set error message
return Json(!isExists, JsonRequestBehavior.AllowGet);
else if(something)
//another logic
//Set errror message
return Json(something, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
默认情况下,仅使用属性声明中的ErrorMessage值进行远程验证
[Remote("IsUserEmailExists", "Account", ErrorMessage = "User with such email already exists")]
Run Code Online (Sandbox Code Playgroud)
有没有办法改变这种行为?