Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all
i have one jscript file like:
saveSticky = function saveSticky() {
	        type: "POST",
	        url: "Home.aspx/MethodSample",
	        data: "{}",
	        contentType: "application/json; charset=utf-8",
	        dataType: "json",
	        success: function succ(msg) {
	            alert('Called Ajax Method');
	        failure: function (response) {
	    var that = $(this), sticky = (that.hasClass("sticky-status") || that.hasClass("sticky-content")) ? that.parents('div.sticky') : that,
                obj = {
                    id: sticky.attr("id"),
                    top: sticky.css("top"),
                    left: sticky.css("left"),
                    text: write = sticky.children(".sticky-content").html().search(document.getElementById("lblusername").value) <= 0 ? sticky.children(".sticky-content").html() + document.getElementById("lblusername").value : sticky.children(".sticky-content").html()
	    localStorage.setItem("sticky-" +, JSON.stringify(obj));

	    // alert('end to save stickey sticky-' + + ' ' + JSON.stringify(obj));

am debug script code it works fine i did't get any errors while running code but
jquery method wont calling webmethod every time
my web method is like:
   public static void MethodSample()
       string str = "Hello World";

so that i tried calling method like:
url: "organozation/Home.aspx/MethodSample"

but again it wont working i tried allot with different type but am not getting result so how can i call web method here...
can any one please help me..
thanks in advance
Updated 25-Dec-11 21:21pm

1 solution

You need to add this code in web.config to enable calling WebMethods from javascript

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


I missed the exact version for the ScriptHandler

For VS 2008. You need to use this

       <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Share this answer
tulasiram3975 26-Dec-11 4:29am    
Sir I added this To config File But It wont calling...
bbirajdar 26-Dec-11 8:06am    
I have added the exact version of script handler above. Try with this one

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