Click here to Skip to main content
15,914,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I could not access service side method from javascript. Here i placed my code
JavaScript
ShowTable = function()
{
    var Obj= $get('pid').value;
    PageMethods.GivemeContent(Obj,OnSuccess)
    alert(Obj);

}
OnSuccess= function(result)
{
  var Obj= $get('mydiv');
  Obj.innerHTML=result;
}


server side:
C#
[System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]

       public static string GivemeContent(string value)
    {
        return @"DemoString";
    }


XML
<ajax:ScriptManager ID="ScriptManager1" runat="server"
       EnablePageMethods="true" EnablePartialRendering="true">
            </ajax:ScriptManager>
       <ajax:UpdatePanel ID="myupdatePanel" runat="server" UpdateMode="Conditional">
       <ContentTemplate>
       <div>
       Your Name :
       <asp:TextBox ID="pid" runat="server" ></asp:TextBox>
       <input id="btn" type="button" value="Show Table" onclick="ShowTable()"/>
       </div>
       <div id="mydiv" runat="server">
         </div>
       </ContentTemplate>
       </ajax:UpdatePanel>
Posted
Updated 8-Dec-11 23:35pm
v2

1 solution

XML
<httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </httpModules>

I Found myself. if added these lines in web config file. it is working
 
Share this answer
 
Comments
thatraja 9-Dec-11 6:16am    
Take a 5!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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