0

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...

2 Answers 2

2

perhaps you should try

/IsValidField

the problem is your path

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

Can you provide me an example of how I can return a JSON object because I didn't find this namespace. I didn't find the ActionResult namespace either. So, I don't understand how I can use the proposed solution.
You can use Sys.Serialization.JavaScriptSerializer to create the json object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.