ICallback & JSON Based JavaScript Serialization
page 1 of 3
Published: 10 Jan 2008
In this article, Muhammad examines how to accomplish JavaScript Serialization using ICallback and JSON. He begins with a basic introduction to ICallback, ICallbackEventHandler interface, and JSON. He then delves deep into the implementation of both server and client side ICallback with the help of associated source code.
by Muhammad ADnan Amanullah
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 35114/ 32
Article Contents:


While working in ASP.NET, sometimes we need to call server side methods asynchronously without having a postback. Sometimes it is either a full page postback or partial page postback. But thanks to the ASP.NET team, we are provided implementation of ICallback very easily.


ICallback is lightweight process. It uses well known XMLHTTP object internally to call server side method. It does not cause page postback and does not cause page rendering. If we are to show output at the client side, we need to make output HTML ourselves and render the controls manually.


ICallback is implemented in ASP.NET by using ICallbackEventHandler interface. It has two methods; one of them is used to call from JavaScript (client side code) and other one returns the result asynchronously back to the JavaScript function.

We just need to perform some action through server side code at server side. It then needs to return the results, but results are in instance or object of any class which would not be easy for JavaScript code to handle. Here we prefer JSON which stands for JavaScript Object Notation.

View Entire Article

User Comments

Title: gh   
Name: ghgh
Date: 2012-07-16 2:53:08 AM
Title: Problem in JQuery autocomplete with asp.net callback using ICallbackEventHandler   
Name: Anuj Rathi
Date: 2012-06-30 10:19:21 PM
I also love ICallback feature of .net & I always use it instead of other Ajax call. I am facing a problem with jquery autocomplete when I use Callback.

Please have a look below post:

Please give me any suggestion.
Title: 5   
Name: 5
Date: 2012-06-07 3:41:30 AM
Title: Re: Mustafa   
Name: Author
Date: 2011-07-07 6:46:42 AM
you need to deserialize json to javascript.

check this http://www.json.org/js.html

Title: Superb   
Name: Mustafa
Date: 2011-07-07 6:28:18 AM
Thingking in C++ (OOP), Web Applications has been tough for me. Thanks you made it quite easy to digest.
Just a question (I am new to Javascript), How do I convert{"Name":"Muhammad Adnan","Age":24} back to Javascript structure so I can access it like this, var strName = arg["Name"]?
Title: RaiseCallBack   
Name: siva
Date: 2011-02-08 6:30:51 AM
very nice...
Title: hi   
Name: how r u
Date: 2010-03-28 11:21:18 AM
That's Nice
Title: oh,yeah   
Name: cristian
Date: 2010-01-05 4:37:31 AM
good article
Title: RaiseCallBackEvent   
Name: Anil Trimbake
Date: 2009-02-27 10:34:39 AM
Its really amazing!
Title: Re: cm object?   
Name: Brendan Enrick
Date: 2009-01-19 8:39:06 AM
@Jeff thank you for pointing this out.

@Muhammad Adnan I have corrected the code in Listing 3. Please make sure everything is correct now. Have a great day.
Title: Re: cm object?   
Name: Author (Muhammad Adnan)
Date: 2008-04-09 9:25:45 AM
sorry its my mistake.
it should be scriptMgr rather than cm
and should be like this
scriptMgr.RegisterClientScriptBlock(this.GetType(),"CallServer", callbackScript, true);

thanks for pointing out and being cause of correction.
Title: cm object?   
Name: jeff
Date: 2008-04-09 7:12:06 AM
In the Page_Load of your sample you call RegisterClientScriptBlock from an object called "cm". Where does that object come from?
Title: RE: Gorhal   
Name: Author
Date: 2008-03-16 1:58:34 PM
what if you have to call method of you page class or any class which is not web service class :) and sometimes clients doesn't feel confident about to use any third party library (i mean JAYROCK) then what? :)

anyhow approaches are 1000000000. i tried to cover up few things like callback, json, javascript serialization in simple and basic manner.

i hope if u look in that way u will feel it better

thanks :)
Title: Re: S.Aprelov , Brandon M. Hunter   
Name: Author
Date: 2008-03-16 1:44:46 PM
for more details about callback and for having more better real time example i would prefer you to look at my another article on this link http://aspalliance.com/1537

hope you find that more appropriate. thanks,
Title: Good Article   
Name: Brandon M. Hunter
Date: 2008-03-16 7:36:50 AM
Good Article, but I agree with S.Aprelov, I would like to see more "real world" examples, but overall its a good article.

Thanks for the article.
Title: Nice but...   
Name: gorhal
Date: 2008-03-15 8:35:59 PM
Nice article!

But I would prefer to use a webservice from javascript. And when using JSON, I would recommend Jayrock. It really rocks ;)
Title: In Response to Author' Reply   
Name: Bobo
Date: 2008-03-13 8:47:53 AM
Thanks for your immediately reply,Muhammad,I'm reading the article you recommended.

Best regards.
Title: Re: Good but not so   
Name: Muhammad Adnan (Author)
Date: 2008-03-13 1:29:01 AM
Thanks for your feedback. Actually, everything couldn't be clear about any topic in a single article. For more details on this topic with different scenario, i would like to refer you to next version of this article which is posted on following link http://aspalliance.com/1573 i hope you find that in more detail

best regards,
Title: Good but not so   
Name: Bobo
Date: 2008-03-12 10:38:11 PM
Good article,but not so clear and detailed. More is required.
Title: Excellent Effort   
Name: Ali Raza CT0-247
Date: 2008-02-21 1:41:15 AM
Woo Thats great
Now i can enjoy with JSON... thx Adnan....
Title: good aticle   
Name: king
Date: 2008-01-30 9:54:28 PM
thank you,i know how to use json now!
Title: Excellent Effort   
Name: Abdul Mannan CT0-247
Date: 2008-01-10 2:10:05 AM
Now i can enjoy with JSON... thx Adnan....

Title: Great Artical   
Name: CTO-Shaukat
Date: 2008-01-10 2:08:32 AM
Nice article on ICallback and JSON. Keep it up adnan

Title: Good One   
Name: Shakeeb Younas
Date: 2008-01-09 8:09:41 AM
Good Work
Title: very good article   
Name: Imran Tareen
Date: 2008-01-09 8:09:06 AM
very knowledge full article.
Title: Good Article   
Name: Zeeshan Fawad
Date: 2008-01-09 6:52:49 AM
Nice Article Sir...
Title: Good Job   
Name: Ejaz Anwer
Date: 2008-01-09 3:14:53 AM
Keep it up.
Title: its really helpful   
Name: Tehreen
Date: 2008-01-08 11:07:59 AM
Good Job Sir!!!!! keep it up.
Title: Call back use   
Name: M Nadeem
Date: 2008-01-08 4:40:52 AM
Its a nice article to use JSON with asp.net the use of AJAX technology. It simple, short and comprehensive article for understanding. I wanna say thanks to adnan because i got the great vision of AJAX in this article in very short time and i can refer to my other friends as well to tell them about this functionality in very short manner.


M Nadeem
Title: Good Article   
Name: Kauser
Date: 2008-01-08 3:34:12 AM
I read this article and I feel that its quite informative and easy to understand. I really like your way of writing. Good Effort!
Title: Nice article   
Name: shahzad sarwar
Date: 2008-01-08 2:45:48 AM
Nice article on ICallback and JSON. Keep it up adnan.
Title: gr8 article   
Name: John
Date: 2008-01-08 2:37:57 AM
by this article i get to know many new things like callback, json, js serialization which i never even bother and now i have plenty of places where i could utlize it. keep it up man :)

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-06-20 8:13:17 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search