Let us have a page named ajaxcall.aspx . We will take a div with id myDiv and put its text "Before ajax call when server side function is not called." Now place a button with id Button1 .
There is a method named ServerSideMethod defined on ajaxcall.aspx.cs page. This method returns the text "After ajax call when server side function is called".
Now we want to call the method ServerSideMethod on the click of button Button1 and change the text of div myDiv to the message returned by ServerSideMethod. To do this we will make the ajax call to the method by following code:
Firstly add the reference:-
After that write the code:
Now when we run the program we have the initial screen:
And after click on the Check button output will be:-
The text of the paragraph has been replaced by the message returned by the method ServerSideMethod.