Tuesday, February 2, 2010

Page Method

Code in aspx page :

[System.Web.Services.WebMethod]
public static string CheckUserAvailability(string sUserId, string sUserName)
{
return CommonFunctions.CheckUserAvailability(sUserId, sUserName);
}

HTML :
<a href="#" onclick="CheckAvailability()">Check User Availability</a>
<span id="lblCheck"></span>

Javascript :

function CheckAvailability() {
PageMethods.CheckUserAvailability(document.getElementById('<%= hdnCurrentUserId.ClientID %>').value, document.getElementById('<%= txtUserName.ClientID %>').value, OnSucceededUser, OnFailedUser);

return false;
}

function OnSucceededUser(result, userContext, methodName) {
document.getElementById('lblCheck').innerHTML = result;
return;
}

function OnFailedUser(error, userContext, methodName) {
return;
}

No comments: