954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Call a C# method with jQuery

I attempted to invoke a C# method using jQuery but it failed. The reason is because the method cannot be found. However the method exist in the class. Did I miss something?

Your help is kindly appreciated.

Thank You

Attachments website.zip (75.46KB)
solomon_13000
Junior Poster in Training
88 posts since Jul 2009
Reputation Points: 24
Solved Threads: 0
 
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Try using Page Methods or web services.

With Page Methods, you will not need to use jQuery.

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx

Remember that your method needs to be static.

stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

Try using Page Methods or web services.

With Page Methods, you will not need to use jQuery.

http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx

Remember that your method needs to be static.

You mean I should replace the code below:

public string returnJson(){
        tojson = Json.ToJSON(people);
        return tojson;
    }


To:

public static string returnJson(){
        tojson = Json.ToJSON(people);
        return tojson;
    }
solomon_13000
Junior Poster in Training
88 posts since Jul 2009
Reputation Points: 24
Solved Threads: 0
 

I found the solution. You may review the attachment.

Attachments website.zip (75.44KB)
solomon_13000
Junior Poster in Training
88 posts since Jul 2009
Reputation Points: 24
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: