本文介绍了如何检查mvc -c#.net中字段的持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我是MVC Pattern新手。我想检查一个字段是否存在。



Hi all

Iam new to MVC Pattern.I want to check a field exist or not.

@Html.TextBoxFor(m => m.employeeid)
@Html.ValidationMessageFor(m => m.employeeid)





当我输入文本框中的员工代码想要显示msg作为id存在,如果它已经存在于数据库中。



如何在mvc中使用任何客户端脚本执行此操作?



在此先感谢

Amritha



When i entered a employee code in textbox want to show msg as id exist if its already exist in database.

How to do this in mvc using any client side scripting ??

Thanks in Advance
Amritha

推荐答案






行动方法





Action method

[HttpGet]
       public JsonResult IsEmployeeExist(string empId)
       {
           var isEmployeeExist = //here do your db validation and return true or false;

           return Json(isEmployeeExist, JsonRequestBehavior.AllowGet);
       }





以下是关于此的精彩视频:


这篇关于如何检查mvc -c#.net中字段的持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:15