If any one wants to be pass data from code behind to javascript then use WebMethod and PageMethod which normaly working as like core ajax when we have to create webmethod at code behind with return type as writen bellow code:
1. Call Web Method in Javascript using PageMethod technique:
Code Behind Page:
-----------------------------------------------------------
step 1: Create one Web Method in code behind page
[WebMethod]
public static int GetValue()
{
int no=10;
return no;
}
step 2: Create javascript function for call web method using PageMethod technique
function GetCodeBehind_Value()
{
PageMethods.GetValue(onsucess,onerror);
}
// These both method is normally used to handling javascript GetCodeBehind_Value() method which is return result value of "onsucess(result)" method if method is sucessfully called other then return value of "onerror(result)" method.
function onsucess(result)
{
alert(result);
}
function onerror(result)
{
alert(result);
}
Note: Plz use ScriptManage and enamblepageload method true.
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
I hope it will help you....... :-)