用户名上的mvc3远程验证进度条

时间:2010-12-09 06:08:34

标签: asp.net-mvc-3

我想在cshtml页面上使用UserName前面的小进度条。我怎么做? 有办法吗?

[Required(ErrorMessage = "{0} is required.")]
[Remote("IsUsernameAvalilable", "Validation")]
public string UserName { get; set; }

public JsonResult IsUsernameAvalilable(string userName)
{

    if (!_repository.UserExists(userName))
        return Json(true, JsonRequestBehavior.AllowGet);

    return Json(String.Format(CultureInfo.InvariantCulture, "{0} is not available.", userName), JsonRequestBehavior.AllowGet);
}

0 个答案:

没有答案