ARTICLE

Call an ASP.NET C# Method (Web Method) Using JQuery

Posted by Venkatesh Kumar Articles | JQuery July 23, 2012
In this article we will see how to call an ASP.NET C# method (Web Method) using jQuery.
Reader Level:
Download Files:
 

Introduction

In this article we will see how to call an ASP.NET C# method (Web Method) using jQuery.

Step 1

Add a jQuery reference to your project.

Jquery1.jpg

Step 2

Add a web method in your page as mentioned below.

Jquery2.jpg

This method simply returns the Server Date time value as a string and the trick is it's a "Static Method", otherwise it won't work.

Step 3

We will use a jQuery "Ajax" method to call, page methods.

Jquery3.jpg

The URL value will be the page name/method name and the data will be the optional parameter to pass the value to the server.

Summary

Now we will call the C# methods and get the post back server data without a page refresh. This is one way to access the C# methods.

Login to add your contents and source code to this article
post comment
     

Thanks for your suggestion.

Posted by Venkatesh Kumar Jul 26, 2012

thanks for the article. you probably should do one that returns a json object instead of a string. :)

Posted by Soon Hong Ooi Jul 26, 2012
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.