In this article I am going to explain about "Remote Validation" using MVC 5.Remote validation is mainly used to check user or mailid exist or not in database ,also you can use for any type of validation using Remote Attribute.
Most of web application needs to check user or mailid exist or not in database ,in that developers needs to write huge amount of code,that's why i am going to achieve this task in very simple steps .Remote validation is normally works as jquery validation.
Before explain about "Remote Validation" ,if you are beginner in MVC that's why i am listing below some important links.
What is Remote validation
Remote validation permits the developer to call the controller action using client side script. This is to a great degree valuable when you need to perform out a back end query without performing a full server side postback.
Implement of "Remote Validation" in MVC Application.
Remote validation is only an Ajax call which approves the client's information. This can undoubtedly be proficient without using ASP.NET MVC 5. The situation for our demo is very basic. We have to ensure that the EmpNameof the new user is one of a kind. The execution beneath makes a basic structure which contains the TextBox control with the id EmpName" and other TextBox control with Id EmpMail.
Follow some simple steps to use remote validation in MVC 5
Step 1:- Create a MVC application.see image...
Step 2:-Create a model "Employee.cs" inside "Model" folder.use this code.
Step 4-Create controller to execute your action ,In this controller you can create any type of action to perform your task.use this code .
Step 5-Right click on Action name "AddUser" add view. In this view i am binding model "Employee" .using Razor control i am creating a login page which is designed by bootstrap and css,jquery. use this code.
Step 6:-Don't forget this step.add these lines in "Web.config" file.use this code inside "<appseting>".
According this image you can see ,i am typing "Bikesh" ,showing error message "Employee name already exists" because i have written hard code "Bikesh" in model.
There are two situation to check validation.
1.you can check only Employee Name
2.you can check both condition "Employee Name" and Email Id.
I hope you understand all things about "Remote validation".if any problem you can download project and run on your system.
You have just read an article that categorized by title MVC by title Part 37::Remote validation in MVC 5,To Check UserName and MailId is Already exist or not.. You can bookmark this page with a URL https://bikeshsrivastava.blogspot.com/2016/09/part-37remote-validation-in-mvc-5to.html. Thank You!
Author: Bikesh Srivastava - Wednesday, 28 September 2016