Monday, July 6, 2009

Call server side method from client script through Ajax

1.Create a class under App_Code folder

public class AjaxFunctions
{

[Ajax.AjaxMethod]
public bool IsNumber(int i)
{
if(i==1)
return true;
else
return false;
}
}


2.Register this class on page_load event of page

Ajax.Utility.RegisterTypeForAjax(typeof(AjaxFunctions));


3. Java script function
function OnChangeFromOwner() {
var res1 = (AjaxFunctions.IsNumber()).value;
}

No comments: