标签:
Model 这样写的
1 [Display(Name = "用户名")]
2 [Required(ErrorMessage = "请填写{0}")]
3 [StringLength(16, MinimumLength = 6, ErrorMessage = "{0}长度必须大于{2}位小于{1}位")]
4 [System.Web.Mvc.Remote("CheckSellerNick", "Login", ErrorMessage = "用户账号已存在")]
public string LoginNo { get; set; }
Controller 里面这样写的
1 [OutputCache(Location = OutputCacheLocation.None, NoStore = true)] //清除缓存
2 public JsonResult CheckSellerNick(string LoginNo)
3 {
4 //bool exists = _userService.LoginNoExist(LoginNo);
5 bool exists = LoginNo.Equals("111111") ? true : false;
6 return Json(exists , JsonRequestBehavior.AllowGet);
7 }
View 这样写的
1 @Html.TextBoxFor(o => o.LoginNo, new { @class = "register_input", maxlength = "16", })
2
3 <div class="register_error">@Html.ValidationMessageFor(o => o.LoginNo)</div>
标签:
原文地址:http://www.cnblogs.com/jiaxiang/p/4568164.html