Click here to Skip to main content
16,019,983 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have declare a function of java script as
XML
<script type="text/javascript">
        function Create_New_control()
        {
            PageMethod.Create_New_Instance();
        }
        </script>


I want call this on blur of textbox so i calls it in .cs file as
txt_comments.Attributes["onblur"] = "Create_New_control()";

And my Function in cs file is defined as
C#
[System.Web.Services.WebMethod]
   public static void Create_New_Instance()
   {
       // Statements
   }


But "Microsoft JScript runtime error: 'PageMethod' is undefined" this error occurs at runtime.


So how i need to do now to resolve this error.


Please suggest me.

Thanks in advance.
Posted
Comments
Ankur\m/ 16-Jun-11 2:14am    
Do you have EnablePageMethods set to true in ScriptManager?
Alizee@CP 16-Jun-11 2:22am    
Yes

Its PageMethods not PageMethod. Also, have you tried setting this in your ScriptManager? EnablePageMethods="true"?
 
Share this answer
 
Comments
Alizee@CP 16-Jun-11 2:19am    
I did it but same error occurs.
Did you enable the pagemethod in the ScriptManager? Enable it and then try again..

<asp:ScriptManager ID="ScriptManager1" runat="server"                EnablePageMethods="true">
</asp:ScriptManager>
 
Share this answer
 
v2
Comments
Alizee@CP 16-Jun-11 2:18am    
I did it but same error occurs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900