Tutorial :Asp.Net WebForm JQuery remote Validation



Question:

I want to do exactly the same thing that in this question : Jquery Validation remote validation not working

The only thing that change is that I'm using Asp.Net WebForm instead of Asp.Net MVC. So, the solution proposed in this post doesn't work for me...

UPDATE

From Jeff comment, here's my new try:

$("#mainForm").validate(  {      rules:      {          UserName:          {              required: true             ,remote: "IsValidField"          }       ,messages:      {          UserName:          {              remote: "UserName has already been choosen. Please choose another one"          }      }     }  

c#

public String IsValidField()  {      String the_field = Request["Field_To_Test"];      JavaScriptSerializer serializer = new JavaScriptSerializer();        if (the_field == another_value)          return serializer.Serialize(true);      else          return serializer.Serialize(true);  }  

If I put a breakpoint the method is never call...


Solution:1

Regardless of webforms or MVC, your page method still has to return a JSON object. So the solution in that post should work fine in a ASP.NET Webforms project.


Solution:2

perhaps you should try

/IsValidField

the problem is your path


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »