Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written this code

// aspx file
XML
<script type="text/javascript">
    function test()
    {
        alert(PageMethods.MyMethod("Paul Hayman"));
    }
</script>


// .cs file
MIDL
[WebMethod]
    public static string MyMethod(string name)
    {

        return "Hello " + name;
    }

But i m not able to access the control on the form in the MyMethod.How to do such kind of things?
Plzz help
Posted

See this one http://www.xdevsoftware.com/blog/post/Call-WebMethod-from-Javascript-in-ASPNET.aspx[^]

BTW if your are still curious I found it with this tool [^]
 
Share this answer
 
Comments
Albin Abel 2-Mar-11 13:06pm    
Enough information. My 5
XML
<script type="text/javascript">
    function test()
    {
      PageMethods.MyMethod("Paul Hayman", OnMyMethodComplete);
    }
    function OnMyMethodComplete(result)
    {
      alert(result);
    }
</script>



<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true" enablepartialrendering="true"/>

I hope the above information will be helpful. If you have more concerns, please let me know.
 
Share this answer
 
v4

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