1. <script language="javascript">
function callserver() {
var tic = $get("txtNoOfTic").value;
// PageMethods.IsTicketAvailable(tic, OnSuccess, OnFailure);
// here tic is parameter passing to the server method
PageMethods.MyMethod(tic, OnSuccess, OnFailure);
}
function OnSuccess(result) {
if (result) {
alert(result);
$get("txtNoOfTic").select();
}
}
function OnFailure(error) {
alert('failture');
}
</script>
[WebMethod]
public static String MyMethod(string s)
{
return "Welcome";
}
2. Add the WebMethod attribute above the method
3. Add the namespace "using System.Web.Services;"
No comments:
Post a Comment