Hi,
I have a very simple login page which I would like to use AJAX with.
User completes username and password fields, hits te button and is shown an 'in progress' image while the request is sent to the server - then the result is returned. I am almost there, but I have an annoyance.
The callback JS function is this:
function attemptLogin_Callback(response) {
if(response.value)
responseMessage.innerHTML = "Credentials accepted.<br/>Please wait...";
else
responseMessage.innerHTML = "Credentials not accepted.<br/>Please try again";
setTimeout('HideProcess();', 2000);
}
and the AjaxMethod is:
[AjaxPro.AjaxMethod()]
public bool attemptLogin(string username, string password)
{
return Security.Logon(username, password);
}
Security.Logon(string, string); is the method used to check the credentials, and is in the same namespace as the AjaxMethod.
Now, if I replace this Security.Logon(username,password) with "true" or "false", the response.value is correctly passed, but when I try to use this Logon method, response.value is always null. response.error is also null.
If I write the result from the Logon method to my page (Response.Write on Page_Load, for example), it displays correctly.
I've tried bringing all of the Logon code into the same class, as an experiement, and marking it as an AjaxMethod, but it still doesn't work.
So, can I not use a separate method to return my result? What am I doing wrong?
Thanks for your help.