Hi,
Use ajax call to hit the Webservice. you need to make your WebMethod static now
ajax call works like this:
function CheckUserNameAvailability(username) {
try {
$.ajax({
type: "POST",
url: "YourForm.aspx/CheckUserNameAvailability",
data: "{'userName':'" + username + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d == "Available") {
alert('Available..........');
}
},
error: function () {
alert('Error occured!');
}
});
} catch (e) {
alert(e);
}
}
Here replace your page name with YourForm.aspx in the url.
send value to parameter username when you call the Method in javascript as
<asp:button id="btnCheckName" runat="server" onclientclick="return CheckUserNameAvailability('username');" xmlns:asp="#unknown" />