0

I have a UserControl (.ascx) and I want to do an Ajax control on the email.

this is my ajax call inside the file Login.ascx

 $.ajax({
            url: "Login.aspx/CheckEmail",
            type: 'POST',
            data: "{email:'"+email+"'}",
            dataType: "json",
            success: function (data) {
                alert("We returned: " + data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
            }
        });

and this is my webMethod in file Login.aspx.cs

  [WebMethod]
    public static string CheckEmail(string email)
    {
        return "it worked";
    }

Now, I always have the Error message that is telling me: Internal Server Error enter image description here

What is wrong here?

thanks

1 Answer 1

1

You can't place the WebMethod inside user controls, you have to place it inside a page or inside a service.

Hope this helps.

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

2 Comments

So if I put the WebMethod inside an aspx page like Login.aspx/CheckEmail it should work? because now the errorThrown is "Internal server Error" maybe there is another error?
Question edited,however thank you because the error is changed ;)

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.