Working with Callback and Control Rendering
page 4 of 8
by Muhammad ADnan Amanullah
Average Rating: 
Views (Total / Last 10 Days): 44682/ 168


1.    Create Server side controls e.g. DropDownLists and GridView

2.    Load Categories on Page load

3.    Implement ICallbackEventHandler interface

4.    Create subcategories data in server memory to bind to Subcategory DropDownLists.

5.    Render control (subcategory DropDownLists) and show output.

6.    Create products data in server memory to bind to Products GridView.

7.    Render Control (products GridView) and return rendered contents to client side to show

8.    Set innerHTML of each control by rendered contents

Create DropDownLists and GridView Controls

Listing 1

<br />
<asp:DropDownList ID="ddlCategories" runat="server" Width="100" onchange="CallSrv(this);">
<br />
<div id="ddlSubcategories">
<div id="grvProducts">        

View Entire Article

User Comments

Title: NIKE NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:09:17 AM
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes.
Title: rendered server controls   
Name: Jatin
Date: 2009-06-26 7:44:22 AM
is it possible to render our gridview and datalist controls instead of "grvProducts" as DIV Tag. ?

Because i have one gridview and datalist now i just want to resfresh with callback ?
so how can i achieve this thing with render ?

thanks in advanced....
Title: Re: master pages   
Name: Muhammad Adnan (Author)
Date: 2009-01-15 10:59:12 AM
It works for sure as i did many many times, you must be missing somewhere else. you might be using this somewhere else so i would suggest you to change its name and then try....

best of luck (y)
Title: master pages   
Name: sw
Date: 2009-01-15 10:54:06 AM
the receiveserverdata function not called while using master pages.even the getcallbackresult returns the correct html.could you please let me know,the reason that could be with this.without master pages it works.[even after prefixing the exact id for the controls it doenot work with master pages]
Title: this.renderedoutput   
Name: snow white
Date: 2009-01-12 11:28:19 PM
The HTML string is proper ,which was got from this.renderedoutput.The problem is ,the function receiveserverdata is not getting called, as i am not getting any alert messages during the button click,after the server side GetCallbackResult() and raisecallbackevents are called.But it works fine for the dropdown changes.
Title: Re: this.renderedoutput   
Name: Muhammad Adnan (Author)
Date: 2009-01-12 9:36:00 AM
Ok its good that you are getting data. Did you check you are getting proper HTML in This.renderedoutput after it get assigned.

If that is also OK then check please in following function that either arg parameter is getting that html string

function ReceiveServerData(arg, context)

just do alert(arg);


If you still having problem, you can email me code or its screenshot.

Thanks and best of luck
Title: This.renderedoutput   
Name: snow white
Date: 2009-01-12 9:22:20 AM

Now i am able to bind the dropdown with the values.But,even if i get data from DB for the datagrid,the datagrid source and all are set fine,it is not visible.can you help me?Even i tried with a gridview.The parameters for the sql query and even the dataset from the query are coming fine.
Title: Re: Re: this.renderedoutput   
Name: Muhammad Adnan (Author)
Date: 2009-01-12 1:55:00 AM
Check whether you are getting data from db or not or you email me at your code i 'll try to see and fix

Title: this.renderedoutput   
Name: snow white
Date: 2009-01-12 1:44:16 AM

Thanks for your quick response.I am now clear with that.But when i tried to bind the dropdowns with db data,everything is fine without any error on debug.But the new dropdowns (created similar to subcategories of this example) are not visible.Should i add any attributes to the controls for changing visibility property.But it works fine with the same example mentioned here.In my design part i have many trs and tds which contain the target div s.Can you help me.
Title: Re: this.renderedoutput   
Name: Muhammad Adnan (Author)
Date: 2009-01-12 12:36:46 AM
You asked about this.renderedoutput
renderedoutput is class level string type variable which i am using in multiple methods/events

Let me know if you have any further query and thanks for your feedback
Title: this.renderedoutput   
Name: snow white
Date: 2009-01-12 12:23:26 AM

This is really a nice article.but i am a new bie.and i get the error "page doe not have a definition for renderedoutput".Can you help me in this.
Title: Re: CallServer   
Name: Author (Muhammad Adnan Amanullah)
Date: 2008-08-18 9:40:50 AM
Thanks for your feedback,

Yes, It is changeable, but make sure wherever it's being using, rename.

Take care, Thanks,
Title: CallServer   
Name: Tapas Pati
Date: 2008-08-18 9:30:04 AM
This topic very good.
Please can you tell mewhat is this (CallServer(arg, context)) function? this name is default or programmer can change it?
Please tell me.
Title: i realy like it   
Name: amol kagde
Date: 2008-08-14 6:46:45 AM

this article is very very useful for me.........

thsnk you for help!!
Title: Nice Article   
Name: Saurabh Maurya
Date: 2008-07-10 2:58:04 AM
Dear Adnan,

Its really a very good article and going to help developers to implement callbacks in their applications.

Hope to hear some more useful information in near future.
Thanks a lot.

Title: Re: KS   
Name: Author
Date: 2008-03-18 1:03:10 AM
First of all, thanks, for your feedback, i would like to explain rendering in somehow informal way, hope you could understand.
Rendering: is somehow conversion of server side code to client side code means when our code executed at web server IIS, it process that request (code) and then in response send back to browser. browser can't understand the code of,, or any server side language code, so it needs to be in that format which it could understand which is client side languages or scripts like html, xhtml, dhtml, javascript,... so in rendering process. our server side language code converted to client side language/script code and return back to browser to interpret.

in my article, i processed the dropdownlists and rendered their output in markup language format and send back to javascript code for browser to interpret.

Title: Working with Callback and Control Rendering   
Name: KS
Date: 2008-03-17 4:37:46 PM
Could you please explain what RenderedOutput is?
Title: Good One   
Name: Uzair Aziz
Date: 2008-03-14 8:17:45 AM
Very good example,this will really helpful if somebody don't want to do programming on dropdown's SelectedIndexChanged Event is really time saving on server side.
Title: Re: Bobo   
Name: Author
Date: 2008-03-14 2:53:10 AM
Yes you are right. it should be:

scriptMgr.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);

thanks :)
Title: A littlte wonder   
Name: Bobo
Date: 2008-03-14 2:47:44 AM
Read,good,but what does "cm" mean in Listing3? it should be scriptMgr,is that correct?
Title: Re: Muhammad Nadeem   
Name: Author
Date: 2008-03-13 1:55:50 PM
surely keep you update next time sir :)
Title: good work   
Name: Muhammad Nadeem
Date: 2008-03-13 10:47:23 AM
hi man good work.. why u did not tell us..
Title: Great piece of work   
Name: Dan Bambling
Date: 2008-03-13 9:37:15 AM
This great, a real help and easy to understand. This sertainly solves having to rely on nested update pannels.
Title: Excelent   
Name: aliraza
Date: 2008-03-13 8:17:38 AM
excellent, very good article
Title: Great Effort i must say.   
Name: Muhammad Moazzam Humayun
Date: 2008-03-13 5:54:21 AM
Wow, very nice article with a superb example.

i have tested it and i love the way u have explained this technique.


Title: Excelent!!!!!!!!!!!!!!!!!!!!!!!!   
Name: cto-Shaukat
Date: 2008-03-13 3:19:37 AM
Excellent article ,it solved a lot of mine problem
Title: Excellent!!!   
Name: Rajasekhar Bathula
Date: 2008-03-13 12:17:02 AM
I have been searching for an like this.Finally,I got it.

Excellent one!!
Title: Very Nice   
Name: Matt
Date: 2008-03-12 1:06:45 PM
Excellent, we've been looking for somethign like this! AJAX partial-postback is just too heavy.
Title: Good Article   
Name: Kauser
Date: 2008-02-05 3:45:38 PM
You have written a very useful article. I will surely try this code. Keep it up!
Title: comments?   
Name: Muhammad Adnan
Date: 2008-02-05 12:37:09 AM
waiting for readerz comments :)

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2020  |  Page Processed at 2020-04-04 10:41:07 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search