hi frens,
i have this small problem,
i want to validate user from ajax post method but i cannot figure out with this code, please help me i have code like this
in the masterpage i have link for signin which pop ups the html table and onclick of the submit button i have called jquery function which calls the ajax post method like this
$(document).ready(function () {
$('#btnSubmit').click(function () {
ValidateUser();
});
});
the ajax method to validate user
unction ValidateUser() {
debugger;
var username = $("#txtUsername").val();
var password = $("#txtPassword").val();
$.ajax
({
type: "POST",
url: "MasterPage.master/UserValidation",
dataType: "json",
data: "{'username':'" + $username + "','password':'" + $password + "'}",
contentType: "application/json; charset=utf-8",
success: function (result) {
alert(result.d);
alert('Login Successful');
},
error: function (result) {
alert(result.d);
alert('Invalide Username or Password');
}
});
};
in the code behind of masterpage i have a webmethod like this that has function to check if the user is valid or not something like this
[WebMethod()]
public int UserValidation(string username, string password)
{
int i = 0;
DataTable dt = Usr.ValidateUser(username, password);
if (dt.Rows.Count > 0)
{
i++;
return i;
}
else
return i;
}
what is my error please help me out thanks guys!!!