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.

Step 2
Add a web method in your page as mentioned below.

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.

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.
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.
Step 2
Add a web method in your page as mentioned below.
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.
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.
No comments:
Post a Comment