Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to call server side function in javascript .
i do't want button click event and webservice method .
Posted

TRY THIS.. :)

Javascript.. :)
JavaScript
function GetData() {
  
            $.ajax({
                type: "POST",
                url: "PageName.aspx/functionName",
                contentType: "application/json;charset=utf-8",
                data: {},
                dataType: "json",
                success: function (data) {

                alert(data.d);
                },
                error: function (result) {
               
                    alert(result.d);

                }
            });

            alert(e.target.result);
         

        }
       
    }
}


c#

C#
[WebMethod]
       public static void functionName()
       {}


html

HTML
<span class="btn btn-info"  önclick="GetData()">GetData</span>
 
Share this answer
 
v3
Comments
Yogesh_Chavan 12-Jul-14 8:38am    
thanks replay sir.. but i do't want webmethod.i want postback event in javascript function..please give me any other solution
Nirav Prabtani 12-Jul-14 8:56am    
Why do you want this kind of functionality??
you can call server side code in javascript using PageMethod

You can refer this link : http://www.dotnetcurry.com/showarticle.aspx?ID=109[^]
 
Share this answer
 

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