Reputation: 1918
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
What is wrong here?
thanks
Upvotes: 0
Views: 632
Reputation: 5269
You can't place the WebMethod inside user controls, you have to place it inside a page or inside a service.
Hope this helps.
Upvotes: 1