Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


C#
$(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


C#
[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!!!
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900