Click here to Skip to main content
12,505,104 members (60,490 online)
Click here to Skip to main content
Add your own
alternative version

Stats

25.5K views
11 bookmarked
Posted

ICallback and JSON based JavaScript Serialization

, 20 Dec 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Callback is a lightweight technique used to call server side methods asynchronously from JavaScript without any postback and reloading/rendering of unnecessary parts of page and unnecessary code.

Introduction

Whilst working with ASP.NET, sometimes we need to call server side methods asynchronously without having to postback whether it is full page postback or a partial page postback. Thanks to the ASP.NET team for providing the implementation of ICALLBACK.

ICALLBACK

ICALLBACK is a lightweight process. It uses the well known XMLHTTP object internally to call a server side method, it doesn’t cause a page postback so doesn’t cause page rendering, so we show the output at the client side. We need to make the output HTML ourselves and render the controls manually.

ICALLBACKEVENTHANDLER

ICALLBACK is implemented in ASP.NET by using the ICALLBACKEVENTHANDLER interface and it has two methods: one of them is used to call from JavaScript (client side code) and the other returns results asynchronously back to the JavaScript function.

We just need to perform some action using server side code at the server side and return results, but results could be an instance or object of any class which need not be easy for the JavaScript code to handle easily, so here we prefer JSON which stands for JavaScript Object Notation.

JSON

JSON is lightweight data-interchange format. ASP.NET gives good support for JSON as well. It’s rapidly being adopted because it is lightweight and easily readable by humans and machines.

Callback Server Side Code

Let’s first implement ICALLBACKEVENTHANDLER to call a server side method asynchronously step by step:

License

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

Share

About the Author

Adnan Aman
Software Developer (Senior) Candoerz
United Kingdom United Kingdom
trying to have can do attitude. Candoerz.com

You may also be interested in...

Pro
Pro

Comments and Discussions

 
General"how to insert data in sql table using Json and icallback eventhandler" Pin
Sreeraam_d13-Dec-12 2:03
memberSreeraam_d13-Dec-12 2:03 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160919.1 | Last Updated 20 Dec 2007
Article Copyright 2007 by Adnan Aman
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid