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.

1

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

3 Comments

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.
@Dipesh Parmar, Only static method you can call by this. but i wanna call non static method.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.