2
.aspx
 -----------------------

    <head>
     <script type="text/javascript">
    >>      $(document).ready(function () {
                $(".cssBtns").click(function () {
                    // call aspx.cs method generateInfo(this.id,this.className)
                });
            });
        </script>
    </head>
    <body>

    </body>

.aspx.cs
-----------------------

    public void generateInfo(int btnId, string className){

         print:// css button id:---
                  css button class:----
    }

how can i call generateInfo method which is aspx.cs page by using java script/JQuery. and which is the best way.

  • possible duplicate of [how to call an ASP.NET c# method using javascript](http://stackoverflow.com/questions/7089760/how-to-call-an-asp-net-c-sharp-method-using-javascript) – Grant Thomas Sep 20 '13 at 08:59

1 Answers1

1

You can use $.ajax(), $.post(), $.get() or $.getJSON() for doing this.

$(".cssBtns").click(function () {
     $.ajax({
        url : 'aspx function path here'
     });
});

See the link below for more reference.

how to call an ASP.NET c# method using javascript

http://api.jquery.com/jQuery.ajax/

Community
  • 1
  • 1
Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90
  • This is a really weak answer to the question, doesn't show handling of parameters (one of the main components of the query) and doesn't even provide reference links. – Grant Thomas Sep 20 '13 at 09:00
  • @Dipesh Parmar, Only static method you can call by this. but i wanna call non static method. –  Sep 20 '13 at 11:20
  • @prasobkumarkp no you can call dynamic functions too but for that you need to code that way....if i know asp.net then i would have helped you but i do not know asp.net so i don't know how it works. – Dipesh Parmar Sep 20 '13 at 11:35