Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [WebMethod]
- public static string LoginValidation(string userName, string passWord)
- {
- string connectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
- SqlConnection con = new SqlConnection(connectionString);
- SqlCommand cmd = new SqlCommand("select * from LoginUser where username = '"
- + userName + "' and password = '" + passWord + "'");
- SqlDataReader rdr = cmd.ExecuteReader();
- if (rdr.HasRows)
- {
- return "succes";
- }
- return "failure";
- }
- $(document).ready(function () {
- $('#txtLogin').focus();
- });
- $('#btnLogin').click(function () {
- var username = $('#txtLogin').val();
- var password = $('#txtPassword').val();
- if (username === "" || password === "") {
- alert('Both the fields are mandatory. Kindly try again');
- $('#txtLogin').focus();
- return;
- }
- else {
- //ajax call to validate the login
- $.ajax({
- type: 'POST',
- data: { 'userName': username, 'passWord': password },
- url: 'Default.aspx/LoginValidation',
- async: true,
- datatype: 'text',
- success: function (data) {
- alert('test sadfadfa '+data+' '+data.responseText);
- if (data == "failure") {
- //redirecting to master page once after the successfull login
- window.location.href = "/masterscreen.aspx";
- }
- else {
- alert('false');
- }
- return;
- },
- error: function (data) {
- }
- });
- //ajax call end
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement