Exploring the depths and potentials of ASP.NET RSS 2.0 or Subscribe to .BenRush by Email
 Thursday, March 22, 2007

RegisterDataItem is a subtle yet powerful member of the ScriptManager class. Unknown to many developers of ASP.Net AJAX is the fact that there can be a back-end data stream flowing from the server to the controls on the client whenever a partial rendering event takes place anywhere on the page. Through RegisterDataItem, you get to register a particular block of data (raw data or JSON serialized data) to a particular control on the client; and client code you place on the page can very easily update that control with its registered data. Example...

Say you have a calendar control on your web form inside an UpdatePanel, and outside the UpdatePanel there exists a Label control whose text should display the selected date of the calendar:

This design is for purposes of this example only; you probably wouldn't always set your system up this way, but for now it suffices.

The question is, how would you go about updating the Label as a result of a refresh of UpdatePanel1 in the example above? The answer is the RegisterDataItem.

In the postback method for clicking a particular date in the calendar, do this:

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
    this.ScriptManager1.RegisterDataItem(this.Label_SelectedDate, this.Calendar1.SelectedDate.ToString());
}
...when this method is called asynchronously, it will register the string data representing our date with Label_SelectedDate. We write a very simple block of client code immediately after our ScriptManager tag in the page:

<script>
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoadingHandler);

function PageLoadingHandler(sender,args){
   var dataItems = args.get_dataItems();
   if($get('Label_SelectedDate')!==null)
   $get(
'Label_Selecteddate').innerHTML = dataItems['Label_SelectedDate'];
   return;
}
</script>

The result will be, whenever you select a date within the calendar, the AJAX runtime will properly update the contents of the label:

This works because the ASP.net AJAX runtime sends the serialized data down to the client framework during the partial rendering of the calendar; the client framework will snag the appropriate bits from this feed and update the controls accordingly through the script we wrote. The "trick" is registering a method with the pageLoading event of the PageRequestManager.


kick it on DotNetKicks.com
Thursday, March 22, 2007 12:40:14 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
AJAX | ASP.Net | Programming
Tracked by:
http://freewebs.com/aspxfaq/14/sitemap16.html [Pingback]
http://freewebs.com/toltom/07/sitemap12.html [Pingback]
http://freewebs.com/toltom/16/stanley-steamer.html [Pingback]
http://freewebs.com/toltom/05/sitemap6.html [Pingback]
http://freewebs.com/toltom/10/bank-of-oklahoma-employment.html [Pingback]
"http://kevruublog.tripod.com/112.html" (http://kevruublog.tripod.com/112.html) [Pingback]
"http://kevruublog.tripod.com/73.html" (http://kevruublog.tripod.com/73.html) [Pingback]
"http://awlelm.org/sitemap9.html" (http://awlelm.org/sitemap9.html) [Pingback]
"http://esrdwu.org/tanya-roberts-nude.html" (http://esrdwu.org/tanya-roberts-nud... [Pingback]
"http://topslots.nl.eu.org/02/sitemap2.html" (http://topslots.nl.eu.org/02/sitem... [Pingback]
"http://freewebs.com/amexa/31/march-madness-bracket.html" (http://freewebs.com/a... [Pingback]
"http://freewebs.com/amexa/08/international-health-insurance.html" (http://freew... [Pingback]
"http://freewebs.com/amexa/35/william-sonoma-home.html" (http://freewebs.com/ame... [Pingback]
"http://pinofranc.homestead.com/01/orlando-resorts.html" (http://pinofranc.homes... [Pingback]
"http://pinofranc.homestead.com/03/hollywood-walk-of-fame.html" (http://pinofran... [Pingback]
"http://pinofranc.homestead.com/01/north-carolina-realestate.html" (http://pinof... [Pingback]
"http://wdall-xxx.com/wife-blow-job.html" (http://wdall-xxx.com/wife-blow-job.ht... [Pingback]
"http://lqtnv-www.com/simulate-a-vagina.html" (http://lqtnv-www.com/simulate-a-v... [Pingback]
"http://gacmuunews.angelfire.com/60.html" (http://gacmuunews.angelfire.com/60.ht... [Pingback]
"http://javboonews.netfirms.com/81.html" (http://javboonews.netfirms.com/81.html... [Pingback]
"http://tadguunews.netfirms.com/189.html" (http://tadguunews.netfirms.com/189.ht... [Pingback]
"http://nbn6i-ooo.com/male-sexual-torture.html" (http://nbn6i-ooo.com/male-sexua... [Pingback]
"http://lasduunews.angelfire.com/71.html" (http://lasduunews.angelfire.com/71.ht... [Pingback]
"http://njq8l-hhh.com/vibrating-cock-rings.html" (http://njq8l-hhh.com/vibrating... [Pingback]
"http://xxx3t-xxx.biz/guy-cumming.html" (http://xxx3t-xxx.biz/guy-cumming.html) [Pingback]
"http://bdgvu-www.biz/shakira-sexy.html" (http://bdgvu-www.biz/shakira-sexy.html... [Pingback]
"http://p4g2f-eee.com/gay-massage.html" (http://p4g2f-eee.com/gay-massage.html) [Pingback]
"http://freewebs.com/retuv/12/fort-lauderdale-hotels.html" (http://freewebs.com/... [Pingback]
"http://freewebs.com/gremi/07/celebration-252224.html" (http://freewebs.com/grem... [Pingback]
"http://freewebs.com/aspxtut/13/magazine-subscriptions.html" (http://freewebs.co... [Pingback]
"http://freewebs.com/rimoq/14/looney-tunes.html" (http://freewebs.com/rimoq/14/l... [Pingback]
"http://freewebs.com/fregat/01/florida-campgrounds.html" (http://freewebs.com/fr... [Pingback]
"http://fkdvh-rrr.com/dennis-rodman-penis-size.html" (http://fkdvh-rrr.com/denni... [Pingback]
"http://unistarkom.ueuo.com/00582-blog.html" (http://unistarkom.ueuo.com/00582-b... [Pingback]
"http://ramambo.nl.eu.org/17/thurgood-marshall.html" (http://ramambo.nl.eu.org/1... [Pingback]
"http://harum.nl.eu.org/wwww-tdwaterhouse-com.html" (http://harum.nl.eu.org/wwww... [Pingback]
"http://ramambo.nl.eu.org/hangar-floor-prep-for-coating.html" (http://ramambo.nl... [Pingback]
"http://grgh1aa.biz/uk-national-lottery.html" (http://grgh1aa.biz/uk-national-lo... [Pingback]
"http://ramamba.nl.eu.org/deals-gap.html" (http://ramamba.nl.eu.org/deals-gap.ht... [Pingback]
"http://hlia9o7.com/sitemap35.html" (http://hlia9o7.com/sitemap35.html) [Pingback]
"http://yanotblog.nl.eu.org/naturist-women.html" (http://yanotblog.nl.eu.org/nat... [Pingback]
"http://alo--fokom.nl.eu.org/www-columbiahouse-co.html" (http://alo--fokom.nl.eu... [Pingback]
"http://freewebs.com/gabeganews/167.html" (http://freewebs.com/gabeganews/167.ht... [Pingback]
"http://pilo--blog.nl.eu.org/ximena-model.html" (http://pilo--blog.nl.eu.org/xim... [Pingback]
"http://sl0zpwo.biz/colorado-state.html" (http://sl0zpwo.biz/colorado-state.html... [Pingback]
"http://liko--blog.nl.eu.org/teen-tickling-orgasm.html" (http://liko--blog.nl.eu... [Pingback]
"http://ple--blog.nl.eu.org/wisconsin-job-center.html" (http://ple--blog.nl.eu.o... [Pingback]
"http://nasferablog.netfirms.com/1.html" (http://nasferablog.netfirms.com/1.html... [Pingback]
"http://toh--blog.nl.eu.org/alabama-inmates.html" (http://toh--blog.nl.eu.org/al... [Pingback]
"http://nasferablog.netfirms.com/170.html" (http://nasferablog.netfirms.com/170.... [Pingback]
"http://fto--kom.nl.eu.org/sitemap1.html" (http://fto--kom.nl.eu.org/sitemap1.ht... [Pingback]
"http://rea--kom.nl.eu.org/lesbian-eat-out.html" (http://rea--kom.nl.eu.org/lesb... [Pingback]
"http://msve--lono.nl.eu.org/reef-flip-flops.html" (http://msve--lono.nl.eu.org/... [Pingback]
"http://repola--loto.nl.eu.org/double-trouble.html" (http://repola--loto.nl.eu.o... [Pingback]
"http://nasferablog.netfirms.com/388.html" (http://nasferablog.netfirms.com/388.... [Pingback]
"http://zf1y1fs.biz/wacoviapersonalbanking.html" (http://zf1y1fs.biz/wacoviapers... [Pingback]
"http://wwad6lf.biz/websterbamk.html" (http://wwad6lf.biz/websterbamk.html) [Pingback]
"http://derfoblog.ifrance.com/sitemap5.html" (http://derfoblog.ifrance.com/sitem... [Pingback]
"http://freewebs.com/sruone/www-disney--com.html" (http://freewebs.com/sruone/ww... [Pingback]
"http://freewebs.com/sruone/sitemap225.html" (http://freewebs.com/sruone/sitemap... [Pingback]
"http://lopbafrea.homestead.com/176.html" (http://lopbafrea.homestead.com/176.ht... [Pingback]
"http://mrwqmcw.info/amy-weber-nude.html" (http://mrwqmcw.info/amy-weber-nude.ht... [Pingback]
"http://freewebs.com/vuter/09/prescription-advantage.html" (http://freewebs.com/... [Pingback]
"http://buter.homestead.com/01/eye-of-the-tiger.html" (http://buter.homestead.co... [Pingback]
"http://freewebs.com/vuter/15/sitemap1.html" (http://freewebs.com/vuter/15/sitem... [Pingback]
"http://duter.homestead.com/00/wells-fargo-acceptance.html" (http://duter.homest... [Pingback]
"http://freewebs.com/datingblogger/1822.html" (http://freewebs.com/datingblogger... [Pingback]
"http://freewebs.com/datingblogger/648.html" (http://freewebs.com/datingblogger/... [Pingback]
"http://fasxen.netfirms.com/26.html" (http://fasxen.netfirms.com/26.html) [Pingback]

Computers Blogs - Blog Top Sites

Archive
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009
Benjamin Rush
Sign In
Statistics
Total Posts: 444
This Year: 0
This Month: 0
This Week: 0
Comments: 128
Themes
Pick a theme:
All Content © 2009, Benjamin Rush
DasBlog theme 'Business' created by Christoph De Baene (delarou)