相关疑难解决方法(0)

如何在SelectList文本描述中组合两个字段?

我想在选定的列表中标注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返回错误,因为没有名为"姓氏名称"的属性.如何在选择列表标签中连接姓名和姓氏?

谢谢

asp.net-mvc selectlist

18
推荐指数
3
解决办法
3万
查看次数

ASP.NET MVC 3远程验证设置自定义错误消息

有没有办法根据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)

有没有办法改变这种行为?

asp.net-mvc-3

9
推荐指数
1
解决办法
6198
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-3 ×1

selectlist ×1