server side method is called only if textbox is empty. This is login form. When I type any username and password, the server side method is not a called at all. If I leave the textboxes empty, everything works . Please help
<form class="login-form" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePageMethods="true" runat="server"></asp:ToolkitScriptManager>
<div class="form-group">
<label class="sr-only" for="form-username">Username</label>
<input id="Username" type="text" placeholder="Username..." class="form-username form-control" />
</div>
<div class="form-group">
<label class="sr-only" for="form-password">Password</label>
<input type="password" id="Password" placeholder="Password..." class="form-password form-control" />
</div>
<button class="btn" onclick="CheckLogin()" >Sign in!</button>
<label id="message"></label>
</form>
Below is the javascript code. It returns data that is used for further checks. If the data is true, we store a session and redirect to index page.
<script>
function CheckLogin() {
var username = $('#Username').val();
var password = $('#Password').val();
alert(password);
PageMethods.LoadDetails(username, password, function (data) {
if (data == "TRUE") {
Session("Userid") = username;
window.location.href = "index.aspx";
}
else {
$('#message').html(data);
}
});
}
</script>
below is the vb code. It calls a class called Marks which contains a function called Load_Details. This function checks to see if user exist and returns true if he does exist.
Imports System.Web.Services
<System.Web.Services.WebMethod()> _
Public Shared Function LoadDetails(ByVal Username As String, ByVal Password As String) As String
Dim Mkz As Marks = New Marks()
Dim holmes As String
holmes = Mkz.load_Details(Username, Password)
Return holmes
End Function