Click here to Skip to main content
13,255,340 members (55,918 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 6 Sep 2012

Ajax Asynchronous postback

, 6 Sep 2012
Rate this:
Please Sign up or sign in to vote.
Ajax Asynchronous Postback Method


Ajax helps the users to send and receive value from server asynchronously.


Using ajax we can send and receive data from server with our reloading the page(postback).  So the page will nor refresh if a server call encounters.

Using the code

A jquery library should be added to avail this ajax functionality to the page.

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

Then we can use $.ajax({}); method in our page script.

syntax for this function

$.ajax({name:value, name:value, ... }

The ajax() method is used to perform an AJAX (asynchronous HTTP) request.

All jQuery AJAX methods use the ajax() method. This method is mostly used for requests where the other methods cannot be used.

Click here for more details

usually this method would be like this.

                   type: "POST",
                   url: "sample.aspx/ShowValue",
                   data: "{'data':'myname','value1':'123456a'}",
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   async: true,
                   success: function (msg) {
                   error: function (msg) {



url: "sample.aspx/ShowValue"  specifies the page name and the function name.

public static string ShowValue(string data, int value1)
    return DateTime.Now.ToString() + " " + data + " " + value1;
the method in the code behind should be a static method.
data: "{'data':'myname','value1':'123456a'}" 

The parameters passed to the code behind as a json object.

A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names. The internal form is an object having get and opt methods for accessing the values by name, and put methods for adding or replacing values by name. The values can be any of these types: Boolean, JSONArray, JSONObject, Number, String, or the JSONObject.NULL object.

myString = new JSONObject().put("JSON", "Hello, World!").toString();
produces the string {"JSON": "Hello, World"}.

the following blog post contains 5 postback in a single button click without user awareness.

Find the full code


Keep a running update of any changes or improvements you've
made here.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Christopher John Paul
Software Developer
India India
I am a software developer with a passion to develop innovative ideas.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Marcus Kramer6-Sep-12 7:11
memberMarcus Kramer6-Sep-12 7:11 
GeneralMy vote of 1 Pin
Selvin6-Sep-12 5:25
memberSelvin6-Sep-12 5:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 6 Sep 2012
Article Copyright 2012 by Christopher John Paul
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid