标签:
[HttpGet]
public ActionResult CheckToolsIdExists(string ToolsID)
{
using (BaseContext context = new BaseContext("ToolsTB"))
{
var isExists = context.T_ToolsSet.FirstOrDefault(m => m.ToolsID == ToolsID);
if (isExists != null)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}
}
[Remote("CheckToolsIdExists", "SystemManagement",ErrorMessage = "伺服机编号已存在!")]
[Required(ErrorMessage = "*编号不能为空!")]
public string ToolsID { get; set; }
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<tr>
<td width="120" align="right">拧紧机编号:</td>
<td>@Html.TextBoxFor(m => m.ToolsID, new { @class = "txt", }) @Html.ValidationMessageFor(m => m.ToolsID)</td>
</tr>
标签:
原文地址:http://www.cnblogs.com/zhoumeng780/p/4704158.html