asp dot net ajax
TRANSCRIPT
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 1/70
ASP.NET AJAX Overview
IntroductionMicrosoft ASP.NET AJAX enables you to quickly create Web pages that inclue a rich user e!perience
"ith responsi#e an fa$iliar user interface %&'( ele$ents. ASP.NET AJAX pro#ies client)script
libraries that incorporate cross)bro"ser E*MAScript %Ja#aScript( an yna$ic +TM, %-+TM,(
technologies an it integrates the$ "ith the ASP.NET /.0 ser#er)base e#elop$ent platfor$. 1y
using ASP.NET AJAX you can i$pro#e the user e!perience an the efficiency of your Web
applications.
Why Use ASP.NET AJAX?
ASP.NET AJAX enables you to buil rich Web applications that ha#e $any a#antages o#er Web
applications that are co$pletely ser#er)base. ASP.NET AJAX applications offer2
← '$pro#e efficiency by perfor$ing significant parts of a Web page3s processing in the
bro"ser.
← 4a$iliar &' ele$ents such as progress inicators tooltips an pop)up "ino"s.
← Partial)page upates that refresh only the parts of the Web page that ha#e change.
← *lient integration "ith ASP.NET application ser#ices for for$s authentication an user
profiles.
← 'ntegration of ata fro$ ifferent sources through calls to Web ser#ices.
← A fra$e"ork that si$plifies custo$i5ation of ser#er controls to inclue client capabilities.
← Support for the $ost popular an generally use bro"sers "hich inclues Microsoft
'nternet E!plorer Mo5illa 4irefo! an Apple Safari.
ASP.NET AJAX Architecture
ASP.NET AJAX consists of client)script libraries an of ser#er co$ponents that are integrate to
pro#ie a robust e#elop$ent fra$e"ork. 'n aition to ASP.NET AJAX you can use the ASP.NET
AJAX *ontrol Toolkit an the features in the ASP.NET AJAX 4utures releases "hich are both
co$$unity supporte.
1
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 2/70
The follo"ing illustration sho"s the functionality that is inclue in the client)script libraries an
ser#er co$ponents.
ASP.NET AJAX ser#er an client architectureThe illustration sho"s the functionality of the client)base Microsoft AJAX ,ibrary "hich inclues
support for creating client co$ponents bro"ser co$patibility an net"orking an core ser#ices.
The illustration also sho"s functionality of ser#er)base ASP.NET /.0 AJAX E!tensions "hich
inclues script support Web ser#ices application ser#ices an ser#er controls.
ASP.NET AJAX Server Architecture
The ASP.NET AJAX ser#er co$ponents consist of ASP.NET Web ser#er controls an co$ponents to
$anage the &' an flo" of an application an to $anage seriali5ation #aliation control
e!tensibility an so on. There are also ASP.NET Web ser#ices that enable you to access ASP.NET
application ser#ices for for$s authentication an user profiles.
ASP.NET AJAX Server Controls
The ASP.NET AJAX ser#er controls consist of ser#er an client coe that integrate to prouce AJAX)
like beha#ior. The follo"ing list escribes the $ost frequently use ASP.NET AJAX ser#er controls.
ScriptManager Manages script resources for client co$ponents partial)page renering locali5ation
globali5ation an custo$ user scripts. The ScriptManager control is require in orer to use
the &patePanel &pateProgress an Ti$er controls.
2
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 3/70
&patePanel Enables you to refresh selecte parts of the page instea of refreshing the "hole page by
using a synchronous postback.
&pateProgress Pro#ies status infor$ation about partial)page upates in &patePanel controls.
Ti$er Perfor$s postbacks at efine inter#als. 6ou can use the Ti$er control to post the "hole
page or use it together "ith the &patePanel control to perfor$ partial)page upates at a
efine inter#al.
ASP.NET AJAX We Services
ASP.NET AJAX pro#ies Web ser#ices that you can use fro$ client script to "ork "ith ASP.NET
application ser#ices for for$s authentication an user profiles. This enables you to use client script
to help protect resources by using for$s authentication an to persist user)specific settings on theser#er. 'n aition ASP.NET AJAX inclues net"ork co$ponents that $ake it easy to return results
fro$ any Web ser#ice call. 4or infor$ation an e!a$ples see Asynchronous *o$$unication ,ayer
7#er#ie" an ASP.NET Application Ser#ices.
ASP.NET AJAX Server Control E!tensiility
ASP.NET AJAX enables you to create custo$ ASP.NET AJAX ser#er controls that inclue client
beha#iors. 4or $ore infor$ation see the tutorials in ASP.NET AJAX E!tensibility an the Microsoft
ASP.NET AJAX *ontrol Toolkit.
ASP.NET AJAX Client Architecture
The ASP.NET AJAX client)script libraries consist of Ja#aScript %.8s( files that pro#ie features for
ob8ect)oriente e#elop$ent. The ob8ect)oriente features inclue in the ASP.NET AJAX client)
script libraries enable a high le#el of consistency an $oularity in client scripting. The follo"ing
layers are inclue in the ASP.NET AJAX script libraries2
← A bro"ser co$patibility layer. This pro#ies co$patibility across the $ost frequently use
bro"sers %incluing Microsoft 'nternet E!plorer Mo5illa 4irefo! an Apple Safari( for your
ASP.NET AJAX scripts.
← ASP.NET AJAX core ser#ices "hich inclue e!tensions to Ja#aScript such as classes
na$espaces e#ent hanling inheritance ata types an ob8ect seriali5ation.
← An ASP.NET AJAX base class library "hich inclues co$ponents such as string builers an
e!tene error hanling.
3
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 4/70
← A net"orking layer that hanles co$$unication "ith Web)base ser#ices an applications
an that $anages asynchronous re$ote $etho calls.
← Support for Ja#aScript libraries that are either e$bee in an asse$bly or are pro#ie as
stanalone Ja#aScript %.8s( files. E$being Ja#aScript libraries in an asse$bly can $ake it
easier to eploy applications an can sol#e #ersioning issues.
← Support for accessing ser#er)base for$s authentication an profile infor$ation in client
script. This support is also a#ailable to Web applications that are not create by using
ASP.NET as long as the application has access to the Microsoft AJAX ,ibrary.
← Support for release an ebug $oes an locali5ation support for both asse$bly)e$bee
an stanalone Ja#aScript files. 4or $ore infor$ation see the ASP.NET AJAX -ebugging
an Tracing 7#er#ie" an ,ocali5ing 9esources for *o$ponent ,ibraries 7#er#ie".
"eu##in#
The ASP.NET AJAX architecture pro#ies a $oel for release an ebug $oes. 9elease $oe
pro#ies error checking an e!ception hanling opti$i5e for perfor$ance "ith $ini$i5e script
si5e. -ebug $oe pro#ies $ore robust ebugging features such as type an argu$ent checking.
'f you create ebug #ersions of custo$ client scripts or script resources ASP.NET runs the ebug
#ersions "hen the application is in ebug $oe. This enables you to thro" e!ceptions in ebug
scripts "hile $ini$i5ing the si5e of release coe.
A ebug helper class Sys.-ebug pro#ies $ethos for isplaying ob8ects in reaable for$ at the
en of a Web page. 't also sho"s trace $essages enables you to use assertions an lets you breakinto the ebugger. An e!tene Error 7b8ect ob8ect AP' pro#ies helpful e!ception etails "ith
support for release an ebug $oes.
← 4or $ore infor$ation see the ASP.NET AJAX -ebugging an Tracing 7#er#ie" an
,ocali5ing 9esources for *o$ponent ,ibraries 7#er#ie".
$oc%li&%tion %nd 'lo%li&%tion
The ASP.NET AJAX ser#er an client architecture pro#ies a $oel for locali5ing an globali5ing
client script. This enables you to esign applications that use a single coe base to pro#ie &' for$any locales %languages an cultures(. 4or e!a$ple ASP.NET AJAX enables Ja#aScript coe to
for$at -ate or Nu$ber ob8ects auto$atically accoring to culture settings of the user3s bro"ser
"ithout requiring a postback to the ser#er
ASP.NET AJAX buils on the founation of the ASP.NET /.0 locali5ation $oel. 't pro#ies aitional
support for locali5e script files that are e$bee in an asse$bly or that are pro#ie as .8s files
4
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 5/70
on isk. ASP.NET AJAX can ser#e locali5e client scripts an resources auto$atically for specific
languages an regions.
4or $ore infor$ation see the follo"ing topics2
← ,ocali5ing 9esources for *o$ponent ,ibraries 7#er#ie"
← E$being ,ocali5e 9esources for a Ja#aScript 4ile
← :lobali5ing a -ate by &sing *lient Script
ASP.NET AJAX Control Tool(it
The ASP.NET AJAX *ontrol Toolkit is a collection of sa$ples an co$ponents that sho" you so$e of
the e!periences you can create "ith rich client ASP.NET AJAX controls an e!teners. The *ontrol
Toolkit pro#ies sa$ples an a po"erful S-; to $ake it si$ple to create an reuse custo$ controls
an e!teners. 6ou can o"nloa the ASP.NET AJAX *ontrol Toolkit fro$ the ASP.NET A8a! Web site.
The ASP.NET AJAX *ontrol Toolkit is co$$unity supporte.
ASP.NET AJAX Co))unity*su++orted ,utures -ele%ses
The ASP.NET AJAX co$$unity)supporte 4utures releases pro#ie features that e!ten the core
ASP.NET AJAX platfor$ "ith functionality that re$ains uner e#elop$ent an that is not inclue
in the Microsoft ASP.NET AJAX release. This inclues aitional e!tener controls support for client
eclarati#e synta! %!$l)script( an $ore. To o"nloa an learn $ore about the 4utures
release see the ASP.NET AJAX Web site.
See Also
← 'nstalling ASP.NET AJAX
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
The U+d%teP%nel %nd U+d%tePro#ress Controls
Introduction
5
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 6/70
Partial)page renering $akes it unnecessary for the "hole ASP.NET page to be refreshe as the
result of a postback. 'nstea only the region of the page that has to be refreshe is upate. As a
result users o not see the "hole page reloa "ith e#ery postback "hich $akes user interaction
"ith the Web page $ore sea$less.
In This Section
Partial)Page 9enering 7#er#ie" -escribes partial)page renering an its co$ponents.
&patePanel *ontrol 7#er#ie" -escribes the &patePanel control "hich ientifies a region of the page as upatable using
partial)page renering.
&pateProgress *ontrol 7#er#ie" -escribes the &pateProgress control "hich enables you to isplay status to users "hile an
asynchronous request is pening.
Page9equestManager *lass 7#er#ie" -escribes the client Page9equestManager class "hich $anages partial)page renering in
the bro"ser an enables you to custo$i5e partial)page renering beha#ior.
See Also
P%rti%l*P%#e -enderin# Overview
Introduction
Partial)page renering re$o#es the nee for the "hole page to be refreshe as the result of a
postback. 'nstea only ini#iual regions of the page that ha#e change are upate. As a result
users o not see the "hole page reloa "ith e#ery postback "hich $akes user interaction "ith the
Web page $ore sea$less. Microsoft ASP.NET AJAX enables you to a partial)page renering to ne"
or e!isting ASP.NET Web pages "ithout "riting client script.
This topic contains the follo"ing sections2
← Scenarios
← 4eatures
← 1ackgroun
6
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 7/70
← *oe E!a$ples
← *lass 9eference
Scen%rios
ASP.NET AJAX enables you to e!ten e!isting ASP.NET /.0 applications an to e#elop ne" ones
that incorporate AJAX %Asynchronous Ja#aScript an XM,( functionality. &se ASP.NET AJAX "hen
you "ant to o the follo"ing2
← '$pro#e the user e!perience "ith Web pages that are richer that are $ore responsi#e to
user actions an that beha#e like traitional client applications.
← 9euce full)page refreshes an a#oi page flicker.
← Enable cross)bro"ser co$patibility "ithout "riting client script.
← Perfor$ AJAX)style client?ser#er co$$unication "ithout "riting client script.
← &se the controls an co$ponents fro$ the ASP.NET AJAX *ontrol Toolkit.
← -e#elop custo$ Microsoft ASP.NET AJAX controls.
P%rti%l*P%#e -enderin# ,e%tures
Partial)page renering relies on ser#er controls in ASP.NET AJAX an on client functions in the
Microsoft AJAX ,ibrary. 6ou o not ha#e to use the Microsoft AJAX ,ibrary to enable partial)page
renering because this functionality is pro#ie auto$atically "hen you use the ASP.NET
AJAX ser#er controls. +o"e#er you can use the AP's e!pose in the client library for aitional
AJAX functionality.
The pri$ary features of ASP.NET AJAX that support partial)page renering inclue the follo"ing2
← A eclarati#e $oel that "orks like ASP.NET ser#er controls. 'n $any scenarios you can
specify partial)page renering using only eclarati#e $arkup.
← Ser#er controls that perfor$ the unerlying tasks require for partial)page upates. These
inclue the ScriptManager control an the &patePanel control.
← 'ntegration bet"een ASP.NET AJAX ser#er controls an the Microsoft AJAX ,ibrary for
co$$on tasks. These tasks inclue enabling users to cancel a postback isplaying custo$
7
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 8/70
progress $essages uring an asynchronous postback an eter$ining ho" concurrent
asynchronous postbacks are processe.
← Error)hanling options for partial)page renering "hich enable you to custo$i5e ho" errors
are isplaye in the bro"ser.
← *ross)bro"ser co$patibility "hich is built into the Microsoft AJAX ,ibrary. Si$ply using the
ser#er controls auto$atically in#okes the correct bro"ser functionality.
%c(#round
Typical Web pages built "ith ASP.NET Web ser#er controls perfor$ postbacks initiate by a user
action on the page such as clicking a button. 'n the response the ser#er reners a ne" page.
4requently this re)reners controls an te!t that i not change bet"een postbacks.
With ASP.NET AJAX partial)page renering you can refresh ini#iual regions of the page
asynchronously an $ake the page $ore responsi#e to the user. 6ou can i$ple$ent partial)page
renering using ASP.NET Web ser#er controls an optionally "rite client script that uses the AP's in
the Microsoft AJAX ,ibrary.
Server Controls /or P%rti%l*P%#e U+d%tes
To a AJAX functionality to ASP.NET Web pages you ientify ini#iual sections of the page that
you "ant to upate. 6ou then put the content of these sections into &patePanel controls. The
contents of an &patePanel control can be +TM, or other ASP.NET controls. 6ou can a an
&patePanel control to the page as you "oul any other control. 4or e!a$ple in @isual Stuio youcan rag it fro$ the toolbo! to the Web page or you can a it by using eclarati#e $arkup in the
page. The follo"ing e!a$ple sho"s the $arkup for an &patePanel control.
CS
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <!-- Place updatable markup and controls ere --> <ContentTemplate><asp:UpdatePanel>
VB
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <!-- Place updatable markup and controls ere --> <ContentTemplate><asp:UpdatePanel>
1y efault postbacks that originate fro$ controls insie the upate panel %chil controls(
auto$atically initiate asynchronous postbacks an cause a partial)page upate. 6ou can also specify
8
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 9/70
that controls outsie the upate panel cause an asynchronous postback an that they refresh the
&patePanel control3s content. A control that causes an asynchronous postback is referre to as a
trigger. 4or $ore infor$ation about triggers see *reating a Si$ple ASP.NET Page "ith Multiple
&patePanel *ontrols.
An asynchronous postback beha#es $uch like a synchronous postback. All the ser#er page life)cyclee#ents occur an #ie" state an for$ ata are preser#e. +o"e#er in the renering phase only
the contents of the &patePanel control are sent to the bro"ser. The rest of the page re$ains
unchange.
To support partial)page renering you $ust put a ScriptManager control on the page. The
ScriptManager control keeps track of all the upate panels on the page an of their triggers. 't
coorinates partial)page renering beha#ior on the ser#er an eter$ines "hich sections of the
page to rener as a result of an asynchronous postback.
The follo"ing e!a$ple sho"s an &patePanel control "hose content is refreshe "hene#er a
postback originates fro$ insie the panel.
9un @ie"4or $ore e!a$ples of ho" to use &patePanel controls to enable partial)page renering see the
topics liste in the *oe E!a$ples section.
Usin# Client Scri+t /or P%rti%l*P%#e U+d%tes
The E*MAScript %Ja#aScript( Page9equestManager class in the Microsoft AJAX ,ibrary supports
partial)page upates. 't runs in the bro"ser to $anage the response to asynchronous postbacks
an to upate content in ini#iual regions. 6ou o not ha#e to o anything to enable thisfunctionality. 't occurs auto$atically "hen you a one or $ore &patePanel controls an a
ScriptManager control to the page.
6ou can also use Ja#aScript an the Page9equestManager class to custo$i5e partial)page upates
on a page. 4or e!a$ple you can "rite script to gi#e preceence to a specific asynchronous postback
if $ore than one is uner"ay. 6ou can also enable users to cancel postbacks that are in progress.
The follo"ing e!a$ple sho"s client script that pro#ies an e#ent hanler that is calle "hen the
page finishes loaing.
CS
<scr#pt t$pe="te%t&avascr#pt" lan'ua'e="&avascr#pt">var prm = ($s)eb*ormsPa'e+e,uestana'er'etInstance./0prmaddpa'e2oaded.Pa'e2oaded3vent4andler/05unct#on Pa'e2oaded3vent4andler./ 6 custom scr#pt7<scr#pt>
9
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 10/70
VB
<scr#pt t$pe="te%t&avascr#pt" lan'ua'e="&avascr#pt">var prm = ($s)eb*ormsPa'e+e,uestana'er'etInstance./0prmaddpa'e2oaded.Pa'e2oaded3vent4andler/05unct#on Pa'e2oaded3vent4andler./ 6 custom scr#pt
7<scr#pt>
4or $ore infor$ation about ho" to use the Microsoft AJAX ,ibrary for partial)page renering see
Working "ith Page9equestManager E#ents an Page9equestManager *lass 7#er#ie".
En%lin# P%rti%l*P%#e -enderin# Su++ort
6ou enable or isable partial)page renering for a page by setting the EnablePartial9enering
property of the ScriptManager control. 6ou can also specify "hether partial)page renering is
supporte for a page by setting the SupportsPartial9enering property of the ScriptManager control.
'f you o not set the SupportsPartial9enering property an if the EnablePartial9enering property
is true %"hich is the efault( the capabilities of the bro"ser are use to eter$ine "hether partial)
page renering is supporte.
'f partial)page renering is not enable for a page if it has been isable or if it is not supporte in
a bro"ser the page uses fallback beha#ior. Actions that orinarily "oul perfor$ an asynchronous
postback instea perfor$ a synchronous postback an upate the "hole page. Any &patePanel
controls on the page are ignore an their contents are renere as if they "ere not insie an
&patePanel control.
note
ASP.NET Web pages that are configure for legacy renering are not supporte in ASP.NET AJAX. 4or
$ore infor$ation see ASP.NET an X+TM,.
Code E!%)+les
The follo"ing e!a$ple sho"s partial)page renering in action. There are t"o &patePanel controls.
7ne control takes user input an another isplays a su$$ary of the input.
9un @ie"
0ow*to %nd W%l(throu#h To+ics
← 'ntrouction to the &patePanel *ontrol
← *reating a Si$ple ASP.NET Page "ith Multiple &patePanel *ontrols
← &sing the &patePanel *ontrol "ith -ata)1oun *ontrols
10
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 11/70
← &sing the &patePanel *ontrol "ith Master Pages
← *usto$i5ing Error +anling for &patePanel *ontrols
← Working "ith Page9equestManager E#ents
← Ani$ating &patePanel *ontrols
← *anceling an Asynchronous Postback
← :i#ing Preceence to a Specific Asynchronous Postback
Cl%ss -e/erence
The follo"ing table lists the key ser#er classes for partial)page renering.
Class Description
&patePanel Specifies regions of the page to be upate uring partial)page renering.
ScriptManager Manages ASP.NET AJAX co$ponents partial)page renering client
requests an ser#er responses on ASP.NET Web pages.
ScriptManagerPro!y Enables neste co$ponents to a script an ser#ice references to pages
that alreay contain a ScriptManager control in a parent ele$ent.
The follo"ing table lists the key client class for partial)page renering.
Class Description
Page9equestManager
*lass
Manages client partial)page renering an e!poses $e$bers for
custo$ client scripting.
See Also
← &patePanel *ontrol 7#er#ie"
← Page9equestManager *lass 7#er#ie"
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
11
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 12/70
U+d%teP%nel Control Overview
Introduction
ASP.NET &patePanel controls enable you to buil rich client)centric Web applications. 1y using
&patePanel controls you can refresh selecte parts of the page instea of refreshing the "hole
page "ith a postback. This is referre to as perfor$ing a partial)page upate. A Web page that
contains a ScriptManager control an one or $ore &patePanel controls can auto$atically
participate in partial)page upates "ithout custo$ client script.
This topic contains infor$ation about the follo"ing2
Scenarios
1ackgroun
*oe E!a$ples
*lass 9eference
Scen%rios
The &patePanel control is a ser#er control that helps you e#elop Web pages "ith co$ple! client
beha#ior that $akes a Web page appear $ore interacti#e to the en user. *oorinating bet"een
ser#er an client to upate only specifie parts of a Web page usually requires in)epth kno"lege
of E*MAScript %Ja#aScript(. +o"e#er by using the &patePanel control you can enable a Web page
to participate in partial)page upates "ithout "riting any client script. 'f you "ant you can a
custo$ client script to enhance the client user e!perience. When you use an &patePanel control
the page beha#ior is bro"ser inepenent an can potentially reuce the a$ount of ata that is
transferre bet"een client an ser#er.
%c(#round
&patePanel controls "ork by specifying regions of a page that can be upate "ithout refreshing
the "hole page. This process is coorinate by the ScriptManager ser#er control an the client
Page9equestManager class. When partial)page upates are enable controls can asynchronously
post to the ser#er. An asynchronous postback beha#es like a regular postback in that the resulting
ser#er page e!ecutes the co$plete page an control life cycle. +o"e#er "ith an asynchronous
postback page upates are li$ite to regions of the page that are enclose in &patePanel controls
an that are $arke to be upate. The ser#er sens +TM, $arkup for only the affecte ele$ents
to the bro"ser. 'n the bro"ser the client Page9equestManager class perfor$s -ocu$ent 7b8ect
Moel %-7M( $anipulation to replace e!isting +TM, "ith upate $arkup. The follo"ing illustration
12
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 13/70
sho"s a page that is loae for the first ti$e an a subsequent asynchronous postback that
refreshes the content of an &patePanel control.
Partial)page renering o#er#ie"
En%lin# P%rti%l*P%#e U+d%tes
The &patePanel control requires a ScriptManager control in the Web page. 1y efault partial)page
upates are enable because the efault #alue of the EnablePartial9enering property of the
ScriptManager control is true.
The follo"ing e!a$ple sho"s $arkup that efines a ScriptManager control an an &patePanel
control on a page. The &patePanel control contains a 1utton control that refreshes the content
insie the panel "hen you click it. 1y efault the *hilrenAsTriggers property is true. Therefore
the 1utton control acts as an asynchronous postback control.
9un @ie"
13
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 14/70
S+eci/yin# U+d%teP%nel Control Content
6ou a content to an &patePanel control eclarati#ely or in the esigner by using the
*ontentTe$plate property. 'n $arkup this property is e!pose as a <ContentTemplate> ele$ent.
To a content progra$$atically you use the *ontentTe$plate*ontainer property.
When a page that contains one or $ore &patePanel controls is first renere all the contents of
the &patePanel controls are renere an sent to the bro"ser. 7n subsequent asynchronous
postbacks the content of ini#iual &patePanel controls $ight be upate. &pates epen on the
panel settings on "hat ele$ent cause the postback an on coe that is specific to each panel.
S+eci/yin# U+d%teP%nel Tri##ers
1y efault any postback control insie an &patePanel control causes an asynchronous postback
an refreshes the panel3s content. +o"e#er you can also configure other controls on the page to
refresh an &patePanel control. 6ou o this by efining a trigger for the &patePanel control. A
trigger is a bining that specifies "hich postback control an e#ent cause a panel to upate. When
the specifie e#ent of the trigger control is raise %for e!a$ple a button3s *lick e#ent( the upate
panel is refreshe.
The follo"ing e!a$ple sho"s ho" to specify a trigger for an &patePanel control.
9un @ie"The trigger is efine by using the <asp:AsyncPostBackTrigger> ele$ent insie the <Triggers>
ele$ent of the &patePanel control. %'f you are eiting the page in @isual Stuio you can create
triggers by using the UpdatePanelTr#''er Collect#on 3d#tor ialog bo!.(
A trigger3s control e#ent is optional. 'f you o not specify an e#ent the trigger e#ent is the efault
e#ent of the control. 4or e!a$ple for the 1utton control the efault e#ent is the *lick e#ent.
0ow U+d%teP%nel Controls Are -e/reshed
The follo"ing list escribes the property settings of the &patePanel control that eter$ine "hen a
panel3s content is upate uring partial)page renering.
'f the &pateMoe property is set to Always the &patePanel controls content is upate on
e#ery postback that originates fro$ any"here on the page. This inclues asynchronous
postbacks fro$ controls that are insie other &patePanel controls an postbacks fro$ controls
that are not insie &patePanel controls.
'f the &pateMoe property is set to Conditional the &patePanel controls content is upate
"hen one of the follo"ing is true2
When the postback is cause by a trigger for that &patePanel control.
14
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 15/70
When you e!plicitly call the &patePanel control3s &pate%( $etho.
When the &patePanel control is neste insie another &patePanel control an the parent panel is
upate.
When the *hilrenAsTriggers property is set to true an any chil control of the &patePanel control causes a postback. *hil controls of neste &patePanel controls o not cause an upate to
the outer &patePanel control unless they are e!plicitly efine as triggers for the parent panel.
'f the *hilrenAsTriggers property is set to false an the &pateMoe property is set to Always
an e!ception is thro"n. The *hilrenAsTriggers property is intene to be use only "hen the
&pateMoe property is set to Conditional.
Usin# U+d%teP%nel Controls in 1%ster P%#es
To use an &patePanel control in a $aster page you $ust ecie ho" to inclue the ScriptManager control. 'f you inclue the ScriptManager control on the $aster page it can act as the
ScriptManager control for all content pages. %'f you "ant to register scripts or ser#ices eclarati#ely
in a content page you can a a ScriptManagerPro!y control to that content page.(
'f the $aster page oes not contain the ScriptManager control you can put the ScriptManager
control ini#iually on each content page that contains an &patePanel control. The esign choice
epens on ho" you inten to $anage client script in your application. 4or $ore infor$ation about
ho" to $anage client script see ScriptManager *ontrol 7#er#ie". 4or $ore infor$ation about
$aster pages see ASP.NET Master Pages 7#er#ie".
'f the ScriptManager control is on the $aster page an you o not nee partial)page renering
capabilities for a content page you $ust progra$$atically set the EnablePartial9enering property
of the ScriptManager control to false for that content page.
The follo"ing e!a$ple sho"s $arkup for a ScriptManager control on the $aster page an an
&patePanel control on a content page. 'n this e!a$ple a property na$e 2astUpdate is efine
on the $aster page an is reference fro$ insie the &patePanel control.
9un @ie"
Usin# Nested U+d%teP%nel Controls
&patePanel controls can be neste. 'f the parent panel is refreshe all neste panels are refreshe
also.
The follo"ing e!a$ple sho"s $arkup that efines an &patePanel control insie another
&patePanel control. A button in the parent panel triggers an upate of the content in both the
parent an the chil panel. The button in the chil panel triggers an upate of only the chil panel.
15
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 16/70
9un @ie"The follo"ing e!a$ple sho"s a neste &patePanel control "ith a :ri@ie" control. The :ri@ie"
control is insie an &patePanel control an each :ri@ie" ro" contains a neste :ri@ie" control
insie another &patePanel control.
9un @ie"
When an inner :ri@ie" control isplays a ne" page of recors the outer panel an the panels in
the other ro"s of the outer :ri@ie" control are not refreshe. When the outer :ri@ie" control
isplays a ne" page of recors the outer panel an the neste panels are all refreshe.
-e/reshin# %n U+d%teP%nel Pro#r%))%tic%lly
The follo"ing e!a$ple sho"s ho" to refresh an &patePanel control progra$$atically. 'n this
e!a$ple a page registers a control as a trigger by calling the
9egisterAsyncPost1ack*ontrol%*ontrol( $etho. The coe refreshes the &patePanel control
progra$$atically by calling the &pate%( $etho.
9un @ie"
Cre%tin# U+d%teP%nel Controls Pro#r%))%tic%lly
To a an &patePanel control to a page progra$$atically you create a ne" instance of the
&patePanel control. 6ou then a controls to it by using the *ontentTe$plate*ontainer property
an the A%*ontrol( $etho. -o not a controls irectly to the *ontentTe$plate property.
When an &patePanel control is ae progra$$atically only postbacks fro$ controls in the sa$e
na$ing container as the &patePanel control can be use as triggers for the panel.
The follo"ing e!a$ple sho"s ho" to progra$$atically a an &patePanel control to a page. The
e!a$ple as a ,abel an a 1utton control to the upate panel by using the
*ontentTe$plate*ontainer property. 1ecause the *hilrenAsTriggers property is true by efault the
1utton control acts as a trigger for the panel.
9un @ie"
Controls th%t Are Not Co)+%tile with U+d%teP%nel Controls
The follo"ing ASP.NET controls are not co$patible "ith partial)page upates an are therefore not
supporte insie an &patePanel control2
← Tree@ie" an Menu controls.
← Web Parts controls. 4or $ore infor$ation see ASP.NET Web Parts *ontrols.
16
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 17/70
← 4ile&ploa controls "hen they are use to uploa files as part of an asynchronous postback.
← :ri@ie" an -etails@ie" controls "hen their EnableSortingAnPaging*allbacks property is
set to true. The efault is false.
← ,ogin Pass"or9eco#ery *hangePass"or an *reate&serWi5ar controls "hose contents
ha#e not been con#erte to eitable te$plates.
← The Substitution control.
← @aliation controls "hich inclues the 1ase*o$pare@aliator 1ase@aliator
*o$pare@aliator *usto$@aliator 9ange@aliator 9egularE!pression@aliator
9equire4iel@aliator an @aliationSu$$ary control.
*ontrols that are inco$patible "ith partial)page renering can still be use on a page outsie
&patePanel controls. Aitionally in so$e cases you can use the controls in a specific "ay to $ake
the$ co$patible "ith partial)page upates. 4or e!a$ple you can use the ,ogin *hangePass"or
or Pass"or9eco#ery controls insie an &patePanel control if you can con#ert their contents to
te$plates. %'f you are using @isual Stuio in -esign #ie" you can con#ert the controls by using
s$art)tag $enu co$$ans such as Convert to Template or Custom#8e Create User (tep.(
When you con#ert these controls into eitable te$plates the #aliation controls that are use in the
control are efine eclarati#ely by using $arkup in the page. To $ake the #aliators co$patible
"ith an &patePanel control set the Enable*lientScript property of the #aliators to false. This
isables the client script that "oul orinarily be use to perfor$ #aliation in the bro"ser. As a
result uring an asynchronous postback the #aliators perfor$ #aliation on the ser#er. +o"e#er
because only the content of the UpdatePanel is refreshe the #aliators can pro#ie the kin ofi$$eiate feeback that is orinarily pro#ie by client script.
To use a 4ile&ploa control insie an &patePanel control set the postback control that sub$its the
file to be a Post1ackTrigger control for the panel.
All other controls "ork insie &patePanel controls. +o"e#er in so$e circu$stances a control
$ight not "ork as e!pecte insie an &patePanel control. These circu$stances inclue the
follo"ing2
← 9egistering script by calling registration $ethos of the *lientScriptManager control.
← 9enering script or $arkup irectly uring control renering such as by calling the
Write%String( $etho.
'f the control calls script registration $ethos of the *lientScriptManager control you coul use
corresponing script registration $ethos of the ScriptManager control instea. 'n that case the
control can "ork insie an &patePanel control.
17
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 18/70
Code E!%)+les
The follo"ing sections inclue e!a$ples that sho" ho" to create an use &patePanel controls.
0ow*to %nd W%l(throu#h To+ics
← 'ntrouction to the &patePanel *ontrol
← *reating a Si$ple ASP.NET Page "ith Multiple &patePanel *ontrols
← &sing the &patePanel *ontrol "ith -ata)1oun *ontrols
← &sing the &patePanel *ontrol "ith Master Pages
← &sing the &patePanel *ontrol "ith &ser *ontrols
← &sing the &patePanel *ontrol "ith a Web Ser#ice
← *usto$i5ing Error +anling for &patePanel *ontrols
← Working "ith Page9equestManager E#ents
← Ani$ating &patePanel *ontrols
← *anceling an Asynchronous Postback
← :i#ing Preceence to a Specific Asynchronous Postback
Cl%ss -e/erence
The key ser#er classes for &patePanel controls are sho"n in the follo"ing table.
Class Description
&patePanel A ser#er control that specifies the parts of a Web page that canparticipate in partial)page upates.
ScriptManager A ser#er control that $anages partial)page renering. The ScriptManager
control registers script co$ponents to sen to the bro"ser. 't also
o#erries page renering so that only specifie regions of the page are
renere.
ScriptManagerPro!y A ser#er control that enables neste co$ponents %such as content pages
18
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 19/70
or user controls( to a script an Web)ser#ice references. This control is
useful if the parent ele$ent alreay contains a ScriptManager control.
Page9equestManager A class in the Microsoft AJAX ,ibrary that coorinates partial)page
renering in the bro"ser. The Page9equestManager class asynchronously
e!changes infor$ation "ith the ser#er an e!poses e#ents an $ethosfor custo$ client script e#elop$ent.
Addition%l To+ics
ASP.NET Page ,ife *ycle 7#er#ie"
See Also
← 'ntrouction to the &patePanel *ontrol
← *reating a Si$ple ASP.NET Page "ith Multiple &patePanel *ontrols
← &pateProgress *ontrol 7#er#ie"
← Partial)Page 9enering 7#er#ie"
← Page9equestManager *lass 7#er#ie"
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
U+d%tePro#ress Control Overview
IntroductionThe &pateProgress control pro#ies status infor$ation about partial)page upates in &patePanel
controls. 6ou can custo$i5e the efault content an the layout of the &pateProgress control. To
pre#ent flashing "hen a partial)page upate is #ery fast you can specify a elay before the
&pateProgress control is isplaye.
This topic contains infor$ation about the follo"ing2
← Scenarios
← 1ackgroun
← *oe E!a$ples
← *lass 9eference
19
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 20/70
Scen%rios
The &pateProgress control helps you esign a $ore intuiti#e &' "hen a Web page contains one or
$ore &patePanel controls for partial)page renering. 'f a partial)page upate is slo" you can use
the &pateProgress control to pro#ie #isual feeback about the status of the upate. 6ou can put
$ultiple &pateProgress controls on a page each associate "ith a ifferent &patePanel control.
Alternati#ely you can use one &pateProgress control an associate it "ith all &patePanel controls
on the page.
%c(#round
The &pateProgress control reners a <div> ele$ent that is isplaye or hien epening on
"hether an associate &patePanel control has cause an asynchronous postback. 4or initial page
renering an for synchronous postbacks the &pateProgress control is not isplaye.
Associ%tin# %n U+d%tePro#ress Control with %n U+d%teP%nel Control
6ou associate an &pateProgress control "ith an &patePanel control by setting the
Associate&patePanel'- property of the &pateProgress control. When a postback e#ent originates
fro$ an &patePanel control any associate &pateProgress controls are isplaye. 'f you o not
associate the &pateProgress control "ith a specific &patePanel control the &pateProgress
control isplays progress for any asynchronous postback.
'f the *hilrenAsTriggers property of a &patePanel control is set to false an an asynchronous
postback originates fro$ insie that &patePanel control any associate &pateProgress controls
"ill be isplaye.
Cre%tin# Content /or the U+d%tePro#ress Control
&se the ProgressTe$plate property to eclarati#ely specify the $essage isplaye by an
&pateProgress control. The <ProgressTemplate> ele$ent can contain +TM, an $arkup. The
follo"ing e!a$ple sho"s ho" to specify a $essage for an &pateProgress control.
CS
<asp:UpdatePro'ress ID="UpdatePro'ress1" runat="server"><Pro'ressTemplate>
9n update #s #n pro'ress<Pro'ressTemplate><asp:UpdatePro'ress>
VB
<asp:UpdatePro'ress ID="UpdatePro'ress1" runat="server"><Pro'ressTemplate> 9n update #s #n pro'ress
20
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 21/70
<Pro'ressTemplate><asp:UpdatePro'ress>
The follo"ing e!a$ple sho"s one &pateProgress control that sho"s upate status for t"o
&patePanel controls.
9un @ie"The follo"ing e!a$ple sho"s t"o &pateProgress controls. Each sho"s upate status for an
associate &patePanel control.
9un @ie"The follo"ing e!a$ple sho"s ho" to a a button to the <ProgressTemplate> ele$ent that the
user can click to stop the asynchronous postback. Any ne" postbacks that are initiate "hile
another postback is e!ecuting are cancele.
9un @ie"'n the pre#ious e!a$ple the onClick attribute of an +t$l1utton control in the
<ProgressTemplate> ele$ent calls the Ja#aScript 9bortPostack function. 4or $ore infor$ation
see the abortPost1ack $etho an the is'nAsyncPost1ack property of the Page9equestManager
class.
S+eci/yin# Content $%yout
When the -yna$ic,ayout property is true the &pateProgress control initially occupies no space in
the page isplay. 'nstea the page yna$ically changes to isplay the &pateProgress control
contents "hen neee. To support yna$ic isplay the control is renere as a <div> ele$ent that
has its display style property initially set to none.
When the -yna$ic,ayout property is false the &pateProgress control occupies space in the page
isplay e#en if the control is not #isible. 'n that case the <div> ele$ent for the control has its
display style property set to block an its visibility initially set to hidden.
Puttin# U+d%tePro#ress Controls on the P%#e
6ou can put &pateProgress controls insie or outsie &patePanel controls. A &pateProgress
control is isplaye "hene#er the &patePanel control it is associate "ith is upate as a result of
an asynchronous postback. This is true e#en if the &pateProgress control is insie another
&patePanel control.
'f an &patePanel control is insie another upate panel a postback that originates insie the chil
panel causes any &pateProgress controls associate "ith the chil panel to be isplaye. 't also
isplays any &pateProgress controls associate "ith the parent panel. 'f a postback originates fro$
an i$$eiate chil control of the parent panel only the &pateProgress controls associate "ith the
parent panel are isplaye. This follo"s the logic for ho" postbacks are triggere.
21
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 22/70
S+eci/yin# When U+d%tePro#ress Controls Are "is+l%yed
6ou can progra$$atically control "hen an &pateProgress control is isplaye by using the
Ja#aScript begin9equest an en9equest e#ents of the Page9equestManager class. 'n the
begin9equest e#ent hanler isplay the -7M ele$ent that represents the &pateProgress control.
'n the en9equest e#ent hanler hie the ele$ent.
6ou $ust pro#ie client script to sho" an hie an &pateProgress control in the follo"ing
circu$stances2
← -uring a postback fro$ a control that is registere as an asynchronous postback trigger for
the upate panel but that the &pateProgress control is not associate "ith.
← -uring postbacks fro$ controls that are registere progra$$atically as asynchronous
postback controls by using the 9egisterAsyncPost1ack*ontrol%*ontrol( $etho of the
ScriptManager control. 'n that case the &pateProgress control cannot eter$ine
auto$atically that an asynchronous postback has been triggere.
Code E!%)+les
The follo"ing sections inclue coe e!a$ples for creating an using &pateProgress controls.
0ow*to %nd W%l(throu#h To+ics
← 'ntrouction to the &pateProgress *ontrol
← Progra$$ing &pateProgress *ontrols in *lient Script
Cl%ss -e/erence
The follo"ing table lists the key classes for "orking "ith the &pateProgress class.
Class Description
&pateProgress Pro#ies #isual feeback in the bro"ser "hen the content of &patePanel
controls is upate.
&patePanel Specifies parts of a Web page that can participate in partial)page upates.
ScriptManager Manages partial)page renering. The ScriptManager control registers
script co$ponents to sen to the bro"ser an o#erries page renering
so that only specifie regions of the page are renere.
Page9equestManager *oorinates partial)page renering in the bro"ser. The
Page9equestManager class asynchronously e!changes infor$ation "ith
22
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 23/70
the ser#er an e!poses e#ents an $ethos for custo$ client scripting.
Addition%l To+ics
ASP.NET Page ,ife *ycle 7#er#ie"
See Also
← &patePanel *ontrol 7#er#ie"
← 'ntrouction to the &patePanel *ontrol
← 'ntrouction to the &pateProgress *ontrol
← Progra$$ing &pateProgress *ontrols in *lient Script
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
ASP.NET P%#e-e2uest1%n%#er Cl%ss Overview
Introduction
The Page9equestManager class in the Microsoft AJAX ,ibrary $anages partial)page upates in the
bro"ser. When a page contains a ScriptManager control an one or $ore &patePanel controls the
page is auto$atically enable for partial)page renering. The Page9equestManager class e!poses
properties $ethos an e#ents that enable you to custo$i5e partial)page upates "ith client
script. The Page9equestManager class e!poses a client page e#ent $oel that you can use in a "ay
si$ilar to ho" you use the ser#er page e#ent $oel.
This topic contains2
← Scenarios
← 4eatures
← 1ackgroun
← *oe E!a$ples
← +o")to an Walkthrough Topics
← *lass 9eference
23
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 24/70
Scen%rios
6ou can enable partial)page upates by using the ScriptManager an &patePanel Web ser#er
controls. Partial)page upates require no client scripting. +o"e#er you can use the
Page9equestManager class an client script "hen you "ant to o the follo"ing2
← *ontrol ho" $ultiple asynchronous postbacks are processe. The efault beha#ior is that
the last postback takes preceence. The Page9equestManager class enables you to gi#e
preceence to a specific postback an cancel others that are uner"ay.
← Pro#ie #isual cues or other notification to $ark regions on the page that ha#e been
upate or create as a result of the last asynchronous postback. This can i$pro#e the user
e!perience especially in scenarios "here $ultiple &patePanel controls are use.
← -isplay status $essages uring asynchronous postbacks. 'f postbacks take a long ti$e to
process you $ight "ant to sho" a progress inicator such as an ani$ate i$age. 6ou can
also gi#e the user the option to cancel the postback.
← Pro#ie custo$ error)$essage hanling for partial)page upates. 'f an une!pecte error
occurs uring an asynchronous postback you can hanle the error in client script.
← Access the unerlying request an response ob8ects that are use for the asynchronous
postback.
,e%tures
4eatures of partial)page upates in the Microsoft AJAX ,ibrary inclue the follo"ing2
← *lient page life)cycle e#ents that are raise at key ti$es uring partial)page upates.
← 'nfor$ation about "hich &patePanel controls "ere elete upate or create uring an
asynchronous postback.
← Properties an $ethos that enable you to eter$ine in client script "hether the page is
processing an asynchronous postback. 6ou can also use these $ethos to stop an
asynchronous postback that is uner"ay or to cancel ne" postbacks.
← 'nfor$ation about ser#er ata that is sent to controls that are not participating in partial)
page upates.
%c(#round
24
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 26/70
0ow*to %nd W%l(throu#h To+ics
← Working "ith Page9equestManager E#ents
← Ani$ating &patePanel *ontrols
← *anceling an Asynchronous Postback
← :i#ing Preceence to a Specific Asynchronous Postback
← *usto$i5ing Error +anling for &patePanel *ontrols
Cl%ss -e/erence
The follo"ing table lists the classes that relate to the Page9equestManager class.
Class Description
Page9equestManager *lass Manages client partial)page upates an e!poses $e$bers for
custo$ client scripting.
'nitiali5e9equestE#entArgs
*lass
Pro#ies e#ent ata for the initiali5e9equest e#ent "hich is raise
before the asynchronous request starts.
1egin9equestE#entArgs
*lass
Pro#ies e#ent ata for the begin9equest e#ent "hich is raise
after an asynchronous postback starts an before the postback is
sent to the ser#er.
Page,oaingE#entArgs
*lass
Pro#ies e#ent ata for the page,oaing e#ent "hich is raise after
the response to an asynchronous postback is recei#e but before
any content on the page is upate. This e#ent is not raise if the
postback is stoppe or if an unhanle e!ception is thro"n on the
ser#er uring processing.
Page,oaeE#entArgs *lass Pro#ies e#ent ata for the page,oae e#ent "hich is raise after
all content on the page is refreshe "hether as the result of a
synchronous postback or an asynchronous postback. This e#ent is
not raise if the postback is stoppe or if an unhanle e!ception is
thro"n on the ser#er uring processing.
En9equestE#entArgs *lass Pro#ies e#ent ata for the en9equest e#ent "hich is raise after
an asynchronous postback has finishe.
See Also
26
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 27/70
← &patePanel *ontrol 7#er#ie"
← Page9equestManager *lass 7#er#ie"
← Asynchronous *o$$unication ,ayer 7#er#ie"
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
Scri+t1%n%#er Control Overview
Introduction
The ScriptManager control $anages client script for Microsoft ASP.NET AJAX pages. 1y efault the
ScriptManager control registers the script for the Microsoft AJAX ,ibrary "ith the page. This enables
client script to use the type syste$ e!tensions an to support features such as partial)page
renering an Web)ser#ice calls.
This topic contains the follo"ing sections2
← Why &se the ScriptManager *ontrol
← &sing Type Syste$ E!tensions
← Enabling Partial)Page 9enering
← 9egistering *usto$ Script
← 9egistering Web Ser#ices
← &sing Authentication an Profile Ser#ices fro$ *lient Script
← The ScriptManagerPro!y *ontrol
← *lass 9eference
Why Use the Scri+t1%n%#er Control 6ou $ust use a ScriptManager control on a page to enable the follo"ing features of ASP.NET AJAX2
← *lient)script functionality of the Microsoft AJAX ,ibrary an any custo$ script that you "ant
to sen to the bro"ser. 4or $ore infor$ation see ASP.NET AJAX an Ja#aScript.
27
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 28/70
← Partial)page renering "hich enables regions on the page to be inepenently refreshe
"ithout a postback. The ASP.NET AJAX &patePanel &pateProgress an Ti$er controls
require a ScriptManager control to support partial)page renering.
← Ja#aScript pro!y classes for Web ser#ices "hich enable you to use client script to access
Web ser#ices by e!posing Web ser#ices as strongly type ob8ects.
← Ja#aScript classes to access ASP.NET authentication an profile application ser#ices.
En%lin# P%rti%l*P%#e -enderin#
When a page contains one or $ore &patePanel controls the ScriptManager control $anages
partial)page renering in the bro"ser. The control interacts "ith the page life cycle to upate the
parts of the page that are insie &patePanel controls. 4or $ore infor$ation see Partial)Page
9enering 7#er#ie".
The EnablePartial9enering property of the ScriptManager control eter$ines "hether a page
participates in partial)page upates. 1y efault the EnablePartial9enering property is true.
Therefore partial)page renering is enable by efault "hen you a a ScriptManager control to the
page. 4or infor$ation about ho" to use the &patePanel control "ith the ScriptManager control see
'ntrouction to the &patePanel *ontrol an *reating a Si$ple ASP.NET Page "ith Multiple
&patePanel *ontrols.
0%ndlin# Errors
-uring partial)page renering you can hanle errors by oing the follo"ing2
← Set the Allo"*usto$Errors9eirect property "hich eter$ines ho" the custo$ error
section of the Web.config file is use "hen an error occurs uring an asynchronous
postback.
← +anle the ScriptManager control3s AsyncPost1ackError e#ent "hich is raise "hen there is
a page error uring an asynchronous postback.
← Set the AsyncPost1ackErrorMessage property "hich is the error $essage that is sent to the
bro"ser.
Usin# Ty+e Syste) E!tensions
Microsoft AJAX ,ibrary as type)syste$ e!tensions to Ja#aScript that pro#ie na$espaces
inheritance interfaces enu$erations reflection an helper functions for strings an arrays. These
e!tensions pro#ie functionality in client script that is like that of the .NET 4ra$e"ork. They enable
28
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 29/70
you to "rite ASP.NET /.0 AJAX E!tensions applications in a structure "ay that i$pro#es
$aintainability $akes it easier to a features an $akes it easier to layer functionality. Aing a
ScriptManager control to an ASP.NET Web page auto$atically inclues the type)syste$ e!tensions
so that you can use the library in client script. 4or $ore infor$ation see E!tening Ja#aScript "ith
ASP.NET AJAX.
-e#isterin# Custo) Scri+t
&se the ScriptManager control to $anage resources that you ha#e create for controls that
participate in partial)page upates. 9esources inclue scripts styles hien fiels an arrays. The
Scripts collection of the ScriptManager control contains a Script9eference ob8ect for each script that
is a#ailable to the bro"ser. 6ou can specify the scripts eclarati#ely or progra$$atically.
The ScriptManager control also e!poses registration $ethos that you can use to $anage client
script an hien fiels progra$$atically. When you are registering script or hien fiels that
support partial)page upates you $ust call registration $ethos of the ScriptManager control. %To
register scripts that are not neee for partial)page upates you use $ethos of the
*lientScriptManager class.(
note Any scripts on the page that are registere "ith the ScriptManager control an all e#ent)hanling
script $ust be insie the <form> ele$ent on the page. 7ther"ise the script "ill not be registere or
e!ecute.
4or a list of the *lientScriptManager controls registration $ethos see *reating *usto$ *lient
Script in ASP.NET AJAX an the *lientScriptManager class o#er#ie".
-e#isterin# We Services
The ScriptManager control3s Ser#ices collection contains a Ser#ice9eference ob8ect for each Web
ser#ice that is registere "ith the ScriptManager control. The ASP.NET AJAX fra$e"ork generates a
client pro!y ob8ect for each Ser#ice9eference ob8ect in the Ser#ices collection. The pro!y classes
an their strongly type $e$bers si$plify using Web ser#ices fro$ client script.
6ou can progra$$atically a Ser#ice9eference ob8ects to the Ser#ices collection to register Web
ser#ices at run ti$e. 4or $ore infor$ation see Web Ser#ices.
Usin# Authentic%tion %nd Pro3le Services /ro) Client Scri+t
The Microsoft AJAX ,ibrary inclues pro!y classes for calling the ASP.NET /.0 for$s authentication
an profile application ser#ices irectly fro$ Ja#aScript. 'f you "ant to use a custo$ authentication
ser#ice you can register it using the ScriptManager control. 4or $ore infor$ation see ASP.NET
Application Ser#ices.
29
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 32/70
When the Ti$er control is inclue insie an &patePanel control the Ti$er control auto$atically
"orks as a trigger for the &patePanel control. 6ou can o#errie this beha#ior by setting the
*hilrenAsTriggers property of the &patePanel control to false.
4or Ti$er controls insie an &patePanel control the Ja#aScript ti$ing co$ponent is re)create
only "hen each postback finishes. Therefore the ti$e inter#al oes not start until the page returnsfro$ the postback. 4or instance if the 'nter#al property is set to B0000 $illisecons %B0 secons(
but the postback takes C secons to co$plete the ne!t postback "ill occur BC secons after the
pre#ious postback.
The follo"ing e!a$ple sho"s ho" to inclue a Ti$er control insie an &patePanel control.
<asp:(cr#ptana'er runat="server" #d="(cr#ptana'er1" ><asp:UpdatePanel runat="server" #d="UpdatePanel1"
Updateode="Cond#t#onal"> <contenttemplate> <asp:T#mer #d="T#mer1" runat="server"
Interval="1;"nT#ck="T#mer1T#ck">
<asp:T#mer> <contenttemplate><asp:UpdatePanel>
Usin# % Ti)er Control Outside %n U+d%teP%nel Control
When the Ti$er control is outsie an &patePanel control you $ust e!plicitly efine the Ti$er
control as a trigger for the &patePanel control to be upate.
'f the Ti$er controls is outsie an &patePanel control the Ja#aScript ti$ing co$ponent continues
to run as the postback is being processe. 4or e!a$ple if the 'nter#al property is set to B0000
$illisecons %B0 secons( an the postback takes C secons to co$plete the ne!t postback "ill
occur B0 secons after the pre#ious postback. The user "ill see the refreshe content in the
&patePanel control for only => secons.
6ou $ust set the 'nter#al property to a #alue that enables one asynchronous postback to co$plete
before the ne!t postback is initiate. 'f a ne" postback is initiate "hile an earlier postback is being
processe the first postback is cancele.
The follo"ing e!a$ple sho"s ho" to use the Ti$er control outsie an &patePanel control.
<asp:(cr#ptana'er runat="server" #d="(cr#ptana'er1" ><asp:T#mer ID="T#mer1" runat="server" Interval="1;"
nT#ck="T#mer1T#ck"><asp:T#mer><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Tr#''ers> <asp:9s$ncPostackTr#''er ControlID="T#mer1"
3ventame="T#ck" > <Tr#''ers>
32
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 33/70
<ContentTemplate> <asp:2abel ID="2abel1" runat="server" ><asp:2abel> <ContentTemplate><asp:UpdatePanel>
Code E!%)+les
The follo"ing e!a$ple sho"s an &patePanel control that isplays a rano$ly generate stock price
an the ti$e that the stock price "as generate. 1y efault the Ti$er control upates the content
in the &patePanel e#ery D0 secons. The user can ecie to upate the stock price e#ery D0
secons e#ery B0 secons or not at all. When the user chooses not to upate the stock price the
Enable property is set to false.
cs
<?@ Pa'e 2an'ua'e="CA" 9uto3vent)#reup="true" ?>
<!DCTBP3 tml PU2IC "-)CDTD 4T2 113""ttp:EEEEor'T+%tml11DTD%tml11dtd"><tml %mlns="ttp:EEEEor'1FFF%tml"><ead #d="4ead1" runat="server"> <t#tle>T#mer 3%ample Pa'e<t#tle> <scr#pt runat="server"> protected vo#d Pa'e2oad.ob&ect senderG 3vent9r's e/ 6 r#'#nalT#meTe%t = DateT#meoETo2on'T#me(tr#n'./0 7
protected vo#d T#mer1T#ck.ob&ect senderG 3vent9r's e/ 6 (tockPr#ceTe%t = Het(tockPr#ce./0 T#me5Pr#ceTe%t = DateT#meoETo2on'T#me(tr#n'./0 7
pr#vate str#n' Het(tockPr#ce./ 6 double random(tockPr#ce = J neE +andom./e%tDouble./0 return random(tockPr#ceTo(tr#n'."C"/0 7
protected vo#d +ad#outton1CeckedCan'ed.ob&ect senderG 3vent9r's e/ 6 T#mer13nabled = true0 T#mer1Interval = 10 7
protected vo#d +ad#outton;CeckedCan'ed.ob&ect senderG 3vent9r's e/ 6 T#mer13nabled = true0 T#mer1Interval = K0 7
protected vo#d +ad#outtonCeckedCan'ed.ob&ect senderG 3vent9r's e/ 6 T#mer13nabled = 5alse0 7
<scr#pt><ead>
33
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 34/70
<bod$> <5orm #d="5orm1" runat="server"> <asp:(cr#ptana'er ID="(cr#ptana'er1" runat="server" > <asp:T#mer ID="T#mer1" nT#ck="T#mer1T#ck" runat="server"Interval="1" >
<asp:UpdatePanel ID="(tockPr#cePanel" runat="server"
Updateode="Cond#t#onal"> <Tr#''ers> <asp:9s$ncPostackTr#''er ControlID="T#mer1" > <Tr#''ers> <ContentTemplate> (tock pr#ce #s <asp:2abel #d="(tockPr#ce" runat="server"><asp:2abel><+> as o5 <asp:2abel #d="T#me5Pr#ce" runat="server"><asp:2abel>
<br >
<ContentTemplate> <asp:UpdatePanel> <d#v> <br > Update stock pr#ce ever$:<br > <asp:+ad#outton ID="+ad#outton1" 9utoPostack="true"
Hroupame="T#mer*re,uenc$" runat="server" Te%t="1 seconds"nCeckedCan'ed="+ad#outton1CeckedCan'ed" ><br > <asp:+ad#outton ID="+ad#outton;" 9utoPostack="true"Hroupame="T#mer*re,uenc$" runat="server" Te%t="K seconds"nCeckedCan'ed="+ad#outton;CeckedCan'ed" ><br > <asp:+ad#outton ID="+ad#outton" 9utoPostack="true"Hroupame="T#mer*re,uenc$" runat="server" Te%t="ever"nCeckedCan'ed="+ad#outtonCeckedCan'ed" > <br > Pa'e loaded at <asp:2abel ID="r#'#nalT#me" runat="server"><asp:2abel> <d#v> <5orm><bod$><tml>
vb
<?@ Pa'e 2an'ua'e="L" 9uto3vent)#reup="true" ?>
<!DCTBP3 tml PU2IC "-)CDTD 4T2 1 Trans#t#onal3""ttp:EEEEor'T+%tml1DTD%tml1-trans#t#onaldtd">
<tml %mlns="ttp:EEEEor'1FFF%tml" ><ead #d="4ead1" runat="server"> <t#tle>T#mer 3%ample Pa'e<t#tle> <scr#pt runat="server"> Protected (ub Pa'e2oad.$Lal sender 9s b&ectG $Lal e 9s 3vent9r's/ r#'#nalT#meTe%t = DateT#meoETo2on'T#me(tr#n'./ 3nd (ub
Protected (ub T#mer1T#ck.$Lal sender 9s b&ectG $Lal e 9s 3vent9r's/ (tockPr#ceTe%t = Het(tockPr#ce./ T#me5Pr#ceTe%t = DateT#meoETo2on'T#me(tr#n'./ 3nd (ub
Pr#vate *unct#on Het(tockPr#ce./ 9s (tr#n' D#m random(tockPr#ce 9s Double = J eE +andom./e%tDouble./ +eturn random(tockPr#ceTo(tr#n'."C"/ 3nd *unct#on
34
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 35/70
Protected (ub +ad#outton1CeckedCan'ed.$Lal sender 9s b&ectG $Lal e 9s($stem3vent9r's/ T#mer1Interval = 1 T#mer13nabled = True 3nd (ub
Protected (ub +ad#outton;CeckedCan'ed.$Lal sender 9s b&ectG $Lal e 9s
($stem3vent9r's/ T#mer1Interval = K T#mer13nabled = True 3nd (ub
Protected (ub +ad#outtonCeckedCan'ed.$Lal sender 9s b&ectG $Lal e 9s($stem3vent9r's/ T#mer13nabled = *alse 3nd (ub<scr#pt><ead><bod$> <5orm #d="5orm1" runat="server"> <asp:(cr#ptana'er ID="(cr#ptana'er1" runat="server" > <asp:T#mer ID="T#mer1" nT#ck="T#mer1T#ck" runat="server"Interval="1" >
<asp:UpdatePanel ID="(tockPr#cePanel" runat="server"Updateode="Cond#t#onal"> <Tr#''ers> <asp:9s$ncPostackTr#''er ControlID="T#mer1" > <Tr#''ers> <ContentTemplate> (tock pr#ce #s <asp:2abel #d="(tockPr#ce" runat="server"><asp:2abel><+> as o5 <asp:2abel #d="T#me5Pr#ce" runat="server"><asp:2abel>
<ContentTemplate> <asp:UpdatePanel> <d#v> <asp:+ad#outton ID="+ad#outton1" 9utoPostack="true"Hroupame="T#mer*re,uenc$" runat="server" Te%t="1 seconds"nCeckedCan'ed="+ad#outton1CeckedCan'ed" ><br >
<asp:+ad#outton ID="+ad#outton;" 9utoPostack="true"Hroupame="T#mer*re,uenc$" runat="server" Te%t="K seconds"nCeckedCan'ed="+ad#outton;CeckedCan'ed" ><br > <asp:+ad#outton ID="+ad#outton" 9utoPostack="true"Hroupame="T#mer*re,uenc$" runat="server" Te%t="ever"nCeckedCan'ed="+ad#outtonCeckedCan'ed" ><br > <br > Pa'e or#'#nall$ created at <asp:2abel ID="r#'#nalT#me"runat="server"><asp:2abel> <d#v> <5orm><bod$><tml>
Tutori%ls
'ntrouction to the Ti$er *ontrol
&sing the Ti$er *ontrol "ith Multiple &patePanel *ontrols
35
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 36/70
Cl%ss -e/erence
The key ser#er classes for the Ti$er control are sho"n in the follo"ing table.
Ti$er Perfor$s asynchronous or synchronous Web page postbacks at a efine inter#al.
See Also
← Partial)Page 9enering 7#er#ie"
← &patePanel *ontrol 7#er#ie"
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
Asynchronous Co))unic%tion $%yer Overview
Introduction
The Microsoft ASP.NET AJAX asynchronous co$$unication layer enables a bro"ser to call Web
ser#ice $ethos on the ser#er by using E*MAScript %Ja#aScript(. 't e!poses AP's that Ja#aScript
functions can use in any bro"ser to call Web ser#ice $ethos on the ser#er. These AP's use the
functionality for bro"ser asynchronous beha#ior pro#ie by the bro"ser3s XM,+TTP ob8ect. 4or
$ore infor$ation about the XM,+TTP ob8ect see About Nati#e XM,+TTP on the MS-N Web site.
The asynchronous co$$unication layer pro#ies a clear separation bet"een the business an ata
tiers on the ser#er an the presentation tier on the client. The bro"ser has control of the
presentation tier an pro#ies a rich an responsi#e user interface an the ser#er perfor$s thebusiness an ata tier tasks.
This topic contains the follo"ing infor$ation2
Asynchronous *o$$unication ,ayer 4eatures
1ackgroun
*oe E!a$ples
*lass 9eference
Aitional 9esources
What3s Ne"
36
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 37/70
Asynchronous Co))unic%tion $%yer ,e%tures
The asynchronous co$$unication layer offers the follo"ing features2
Enables Ja#aScript coe to perfor$ asynchronous calls to the ser#er.
*an in#oke $ethos in Web ser#ices that are i$ple$ente as .as$! files.
*an in#oke ASP.NET static page $ethos as if they "ere Web ser#ice $ethos.
*an be configure to enable an isable the ability to call Web ser#ices fro$ ASP.NET AJAX
applications.
Supports a #ariety of seriali5ation for$ats for passing ata bet"een the bro"ser an the
ser#er incluing Ja#aScript 7b8ect Notation %JS7N( string ata an XM, ata.
Makes Web ser#ice interactions easier by generating Ja#aScript pro!ies for Web ser#icesthat can be accesse fro$ client script.
Pro#ies e!tensibility for client e!ecutors that are use by the pro!y ob8ects. An e!ecutor is
a co$ponent that functions as an interface bet"een a client Web request an the net"ork
or other $eia. 6ou can "rite your o"n e!ecutor that plugs into the asynchronous
co$$unication layer. 4or $ore infor$ation see XM,+ttpE!ecutor *lass.
*an be use "ith Meiu$ trust.
1ack to top
%c(#round
The asynchronous co$$unication layer pro#ies an abstraction of lo")le#el co$ponents in the
bro"ser an on the ser#er that enable you to perfor$ client)ser#er co$$unication in Ja#aScript.
AJAX
Asynchronous Ja#aScript an XM, %AJAX( enables you to create $ore interacti#e an $ore
responsi#e Web applications than those that rely e!clusi#ely on co$plete page postbacks. With
AJAX)style progra$$ing the bro"ser can e!change only the ata it nees "ith the ser#er "ithout
ha#ing to upate the co$plete page.
AJAX relies on the follo"ing co$bination of technologies2
Asynchronous co$$unication bet"een the bro"ser an ser#er by using the XM,+TTP
ob8ect that is built into bro"sers.
37
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 39/70
A *onnectingEnPoints.asp! test page. This page contains a button to run the script that
$akes a :ET request an then a P7ST request. The results are returne asynchronously by
the efault Sys.Net.X$l+ttpE!ecutor instance an are isplaye in the page.
The :etTarget.ht$ an the PostTarget.asp! pages. These are the target pages for the :ET
request an the P7ST request respecti#ely.
The supporting *onnectingEnPoints.8s script. This script oes the actual "ork of $aking
the requests an it pro#ies the hanler function "hich recei#es the results of the request.
Client*Server Co))unic%tion
The follo"ing illustration sho"s ho" the asynchronous co$$unication layer co$$unicates bet"een
the client an the ser#er.
*lient)ser#er co$$unication'n physical ter$s part of the asynchronous co$$unication layer is on the client in the for$ of
o"nloae scripts. The other part is on the ser#er in the for$ of hanlers an Web ser#ices.
Client Architecture
The client asynchronous co$$unication layer consists of se#eral Ja#aScript co$ponents. The
follo"ing illustration sho"s the client architecture of the asynchronous co$$unication layer.
39
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 40/70
*lient architectureThe client architecture contains t"o $ain groups2 the co$$unication group an the support group.
Co))unic%tion 'rou+
The co$$unication group contains client script that perfor$s Web ser#ices co$$unication bet"een
the client an the ser#er. Note that Web request hanling is intrinsically an asynchronous process.
The co$$unication group is base on the bro"sers XM,+TTP ob8ect an on e!ecutor ob8ects that
ispatch bro"ser requests to the Web ser#ice.
We Service Pro!y Cl%sses
'n Microsoft ASP.NET AJAX the asynchronous co$$unication layer generates client)script pro!y
classes auto$atically. 6ou can then use the Ja#aScript pro!y ob8ects to $ake asynchronous
requests to the ser#er fro$ client script. There are t"o possible approaches to $aking a Web
ser#ice request2
*alling Web ser#ices by using the +TTP P7ST #erb. A P7ST request has a boy that
contains the ata that the bro"ser sens to the ser#er. 't oes not ha#e a si5e li$itation.
Therefore you can use a P7ST request "hen the si5e of the ata e!cees the intrinsic si5eli$itation for a :ET request. The client seriali5es the request into JS7N for$at an sens it
as P7ST ata to the ser#er. The ser#er eseriali5es the JS7N ata into .NET types an
$akes the actual Web ser#ice call. -uring the response the ser#er seriali5es the return
#alues an passes the$ back to the client "hich eseriali5es the$ into Ja#aScript ob8ects
for processing.
40
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 41/70
*alling Web ser#ices by using the +TTP :ET #erb. This rese$bles the functionality of a
P7ST request "ith the follo"ing ifferences2
M The client uses a query string to sen the para$eters to the ser#er.
M A :ET request can call only a Web ser#ice $etho that is configure by using the
N(cr#ptetod.Use4ttpHet = true/O attribute.
M -ata si5e is li$ite to the &9, length allo"e by the bro"ser.
note
:ET requests are not reco$$ene for $etho calls that $oify ata on the
ser#er or that e!pose critical infor$ation. 'n :ET requests the $essage is encoe
by the bro"ser into the &9, an is therefore an easier target for ta$pering. 4or
both :ET an P7ST requests you shoul follo" security guielines to protect
sensiti#e ata.
P%#e 1ethod Pro!y Cl%sses
Page $ethos pro#ie the scripting infrastructure for client script to call a static $etho in an
ASP.NET page %an .asp! page $aster page or .asc! control( as if it "ere a Web ser#ice $etho.
Su++ort 'rou+
The support group is responsible for hanling pro!y classes an the seriali5ation require for client)
ser#er co$$unication.
Authentic%tion Pro!y Cl%ss
The authentication pro!y class is generate by the ser#er authentication ser#ice. 't enables the user
to log in or log out through Ja#aScript in the bro"ser "ithout $aking a roun trip to the ser#er.
Pro3le Pro!y Cl%ss
The profile pro!y class is generate by the ser#er profile ser#ice. 't $akes the current user3s profileinfor$ation a#ailable to the client through Ja#aScript "ithout $aking roun trips to the ser#er. 't
also enables sa#ing $oifie profile infor$ation to the ser#er by using script.
JSON Seri%li&%tion
41
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 42/70
The client JS7N seriali5ation co$ponent seriali5es Ja#aScript ob8ects into JS7N for$at.
-eseriali5ation is a#ailable by using the Ja#aScript eval function.
Although JS7N is the efault seriali5ation for$at ini#iual $ethos in Web ser#ices an in
ASP.NET Web pages can return alternati#e for$ats such as XM,. The seriali5ation for$at of a
$etho can be specifie "ith attributes. 4or e!a$ple the N(cr#ptetod.+esponse*ormatml/O attribute causes a Web ser#ice $etho to return ata in a bro"ser)specific XM,-ocu$ent type. 4or
$ore infor$ation see XM, -7M Properties in the MS-N ,ibrary an the ScriptMethoAttribute class
o#er#ie".
Server Architecture
The ser#er asynchronous co$$unication layer consists of se#eral co$ponents. The follo"ing
illustration sho"s the ser#er architecture of the asynchronous co$$unication layer.
Ser#er architectureThe ser#er asynchronous co$$unication layer inclues t"o $ain groups2 a co$$unication group
an a support group.
Co))unic%tion 'rou+
The ser#er co$$unication group is the high)le#el interface bet"een the ser#er an the client. 't
contains the ser#er co$$unication co$ponents that correspon to si$ilar co$ponents on the
client.
We Services
'n the Web Ser#ices co$ponent the ser#er perfor$s all the require processing an returns anappropriate response to the client.
P%#e 1ethods
The page)$ethos co$ponent enables a $etho in an ASP.NET page %an .asp! page $aster page
or .asc! control( to be calle as if it "ere a Web ser#ice $etho.
42
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 43/70
Su++ort 'rou+
*o$ponents for the support group hanle aitional tasks such as seriali5ation an application
ser#ices that are require for client)ser#er ata e!change.
JSON Seri%li&%tion
The ser#er JS7N seriali5ation co$ponent enables custo$i5able seriali5ation an eseriali5ation of
co$$on .NET types to an fro$ JS7N for$at.
X1$ Seri%li&%tion
The asynchronous co$$unication layer supports returning XM, types fro$ a Web ser#ice. 'f a Web
$etho returns an X$l-ocu$ent ob8ect as specifie by the ser#er attribute
N(cr#ptetod.+esponse*ormatml/O the callback function recei#es the return #alue as a
bro"ser)specific X$l-ocu$ent type. 4or $ore infor$ation see XM,-ocu$ent Property in the MS-N
,ibrary.
Authentic%tion Service
The authentication ser#ice generates an authentication pro!y class an $akes it a#ailable to client
script. This enables the user to log in or log out through Ja#aScript in the client.
Pro3le Service
The profile ser#ice generates a profile pro!y class "hich can be use in client script to get an setprofile properties for the user ientity associate "ith the current request. The profile ser#ice "orks
for for authenticate users an for anony$ous users "hen the anony$ous ientification feature is
enable.
1ack to top
Code E!%)+les
*alling Web Ser#ices fro$ *lient Script
E!posing Web Ser#ices to *lient Script
&sing 4or$s Authentication
&sing Profile 'nfor$ation
1ack to top
43
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 44/70
Cl%ss -e/erence
Client Ty+es
Name Description
WebSer#icePro!y *lass Enables calling a $etho of a specifie Web ser#ice asynchronously.
Web9equest *lass Moels the infor$ation neee by the asynchronous client)ser#er
co$$unication infrastructure to $ake an +TTP request. This class is
use by other asynchronous client)ser#er co$$unication classes.
Web9equestE!ecutor
*lass )
Pro#ies the functionality for interfacing "ith the net"ork to perfor$
Web requests.
Web9equestManager
*lass
Manages the flo" of net"ork requests fro$ the Web9equest class to
the XM,+ttpE!ecutor class that is responsible for $aking the actual
net"ork requests.
WebSer#iceError *lass +anles errors for the Sys.Net na$espace classes.
XM,+ttpE!ecutor *lass Makes asynchronous net"ork requests using the bro"ser3s XM,+TTP
support.
Ja#aScriptSeriali5er
*lass
Pro#ies seriali5ation an eseriali5ation functionality.
AuthenticationSer#ice
*lass
Pro#ies the client pro!y class for the authentication ser#ice.
Profile:roup *lass -efines a profile group.
ProfileSer#ice *lass Pro#ies the client pro!y class for the profile ser#ice.
Server Ty+es
Name Description
ScriptingAuthenticationSer#iceSection 9epresents the configuration section for authentication
ser#ice settings.
ScriptingProfileSer#iceSection 9epresents the configuration section for profile ser#ice
settings.
Ja#aScript*on#erter Pro#ies an abstract base class for a custo$ type
con#erter.
Ja#aScriptSeriali5er Pro#ies seriali5ation an eseriali5ation functionality.
Ja#aScriptType9esol#er Pro#ies an abstract base class for i$ple$enting a
44
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 45/70
custo$ type resol#er.
Script'gnoreAttribute Specifies that a public property or public fiel "ill be
ignore by the Ja#aScriptSeriali5er "hen seriali5ing or
eseriali5ing an instance of a class.
Si$pleType9esol#er Pro#ies a type resol#er for $anage types.
:enerateScriptTypeAttribute Specifies that the ser#er type $ust be generate in the
pro!y ob8ect.
9esponse4or$at Specifies ho" the Web $etho return type is seriali5e.
ScriptMethoAttribute Specifies "hich +TTP #erb is use to in#oke a $etho
an the for$at of the response.
ScriptSer#iceAttribute 'nicates to the asynchronous co$$unication layer that
a Web ser#ice can be in#oke fro$ script.
AuthenticationSer#iceManager *onfigures the location of the authentication ser#ice.
ProfileSer#iceManager *onfigures the location of the profile ser#ice.
1ack to top
Addition%l -esources
About Nati#e XM,+TTP article on the MS-N Web site
http2??""".8son.org Web site
1ack to top
See Also
← E!posing Web Ser#ices to *lient Script
← &sing Profile 'nfor$ation
← &sing 4or$s Authentication
← *onfiguring ASP.NET AJAX
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
$oc%li&in# -esources /or Co)+onent $ir%ries Overview
Introduction
45
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 46/70
,ocali5ation is the process of custo$i5ing your application for a specific language an culture.
Microsoft ASP.NET AJAX supports the follo"ing locali5ation $oels for "orking "ith client script2
← The .NET 4ra$e"ork resources $oel "ith e!pane support for locali5e resources that
are associate "ith your E*MAScript %Ja#aScript( co$ponents. 'n this $oel you e$be
script files an locali5e script resources in a hub)an)spoke organi5ation of asse$blies%that is you use satellite asse$blies(. 6ou can then selecti#ely use these e$bee client
scripts an resources for specific languages an regions. This $oel enables a single coe
base to support $ultiple cultures.
← Static %stanalone( Ja#aScript files on isk. 'n this $oel locali5e files are groupe in a
single irectory as .8s files instea of e$bee in an asse$bly.
← &pating scripts an script resources that are e$bee in an asse$bly by using static
Ja#aScript files. This $oel enables you to pro#ie aitional locali5ation support for
e$bee scripts an for e$bee resources "ithout requiring any changes to theoriginal asse$bly.
This topic contains the follo"ing infor$ation2
← Scenarios
← 1ackgroun
← ,ocali5ing *lient Scripts an Script 9esources in Asse$blies
← ,ocali5ing Static Script 4iles an Their 9esources
← &sing ScriptManager to Manage Scripts in a *entral ,ocation
← *oe E!a$ples
← *lass 9eference
Scen%rios
ASP.NET AJAX helps client locali5ation for both page e#elopers an co$ponent e#elopers. Page
e#elopers "ill typically locali5e the follo"ing2
← E!ception $essages that are generate fro$ ASP.NET AJAX or co$ponent libraries base
on the bro"sers language setting.
46
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 47/70
← &' for controls such as strings for the Text property of a Button control.
← @alues for public properties of ASP.NET AJAX ser#er controls.
← @alues for properties of client script ob8ects an co$ponents such as non)#isual
co$ponents beha#iors an controls.
*o$ponent e#elopers "ill typically use locali5ation features for the follo"ing2
← ,ocali5ing resources that are reference in coe in Ja#aScript libraries %.8s files(. The
locali5e resources can be eploye in separate installations "ithout rebuiling the $ain
asse$bly or the script library.
← E!posing locali5able properties on ser#er controls that are $appe to properties of client
ob8ects.
%c(#round
,ocali5ation is the process of custo$i5ing your application for a specific language an culture.
ASP.NET AJAX buils on the ASP.NET /.0 locali5ation $oel an pro#ies aitional support for
locali5e script files that are e$bee in an asse$bly or are static .8s files on isk.
'f you are not fa$iliar "ith the ASP.NET locali5ation $oel you can fin infor$ation about it in the
follo"ing topics2
← ,ocali5ing ASP.NET Web Pages &sing 9esources
← +o" to2 *reate 9esource 4iles for ASP.NET Web Sites
← 9esource 4ile :enerator %9esgen.e!e(
$oc%li&in# Client Scri+t ,iles %nd Scri+t -esources in Asse)lies
ASP.NET AJAX takes a#antage of the .NET 4ra$e"ork resources $oel for locali5ation. This $oel
uses a hub)an)spoke arrange$ent to package an eploy locali5e resources that can beincre$entally upate. The hub is the $ain asse$bly that contains the non)locali5e e!ecutable
coe. 't inclues both .NET 4ra$e"ork ser#er coe an any Ja#aScript coe in .8s files that are
e$bee as a resource in the asse$bly.
The $ain asse$bly can also contain the resources for a single culture "hich is referre to as the
neutral or efault culture. The neutral culture is the fallback culture for the applicationthat is the
culture settings that are use if no other culture is specifie.
47
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 48/70
,ocali5e resources for a culture are typically create as na$e?#alue pairs in .res! files. %These
.res! files can also be co$pile into .resources files.( The na$e pro#ies a "ay to access the
infor$ation in coe an the #alue is the locali5e %translate( ter$ i$age or other ele$ent for
that na$e. When an asse$bly is built a type is generate for the .res! file in "hich the na$es are
e!pose as fiels that pro#ie progra$$atic access to the #alues. %6ou specify the na$e of this
generate type as part of the asse$bly properties as escribe later.(
'n the hub)an)spoke $oel each spoke connects to a satellite asse$bly that contains the
resources for a single culture. The satellite asse$bly oes not contain any coe e!ecute by the
ser#er. 't contains only the generate type that pro#ies progra$$atic access to the resource
#alues for that culture.
This $oel offers the follo"ing features2
← 6ou can a resources for ne" cultures by eploying ne" satellite asse$blies after you
ha#e alreay eploye an ASP.NET AJAX asse$bly. -e#eloping culture)specific resources
can require e!tra ti$e. This $oel therefore enables you to release your $ain application
first an eli#er aitional culture)specific resources later.
← 6ou can upate an application3s satellite asse$blies "ithout reco$piling your $ain
asse$bly.
← An application has to loa only the satellite asse$bly for a particular culture instea of
unloaing an reloaing the $ain asse$bly. This can significantly reuce the use of syste$
resources.
4or infor$ation about ho" to create resource files for ASP.NET see +o" to2 *reate 9esource 4iles
for ASP.NET Web Sites an ,ocali5ing ASP.NET Web Pages &sing 9esources.
4or infor$ation about using the .NET 4ra$e"ork resource)file generator %9esgen.e!e( tool see
9esource 4ile :enerator %9esgen.e!e(. This tool con#erts .res! or .t!t files to binary .resources
files that can be linke into asse$blies.
Or#%ni&in# $oc%li&ed 1%in %nd S%tellite Asse)lies
6ou can use the hub)an)spoke $oel "hen you "ant to locali5e an application that inclues
Ja#aScript %.8s( files. 'n general you organi5e the asse$bly as you "oul any ASP.NET application
that is locali5e.
To $anage the Ja#aScript files for an ASP.NET AJAX application you "rite Ja#aScript coe so that it
oes not har)coe strings or other ele$ents that shoul be locali5e. 'nstea in any place "here
the Ja#aScript coe $ust use locali5e #alues you get a fiel fro$ the type that is generate out of
the resource file.
48
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 49/70
The $ain asse$bly typically inclues the follo"ing ele$ents2
← The Ja#aScript files that perfor$ the application tasks an that are "ritten to use locali5e
resources instea of har)coe ones. The asse$bly can optionally inclue ebug #ersions
of these Ja#aScript files.
← 7ptionally the resources %.res! or .resources file( for a single neutral culture "hich acts as
the fallback culture for the application.
← 7ptionally any ebug #ersions of neutral)culture resources. The ebug #ersion of a
resource file inclues any e!tra na$e?#alue pairs that are require for the ebug #ersions
of the Ja#aScript files.
A satellite asse$bly typically inclues locali5e resources for a single culture for the ASP.NET
application. %No satellite asse$bly is require for the fallback culture.( The resources for a single
culture are create in a separate resource file %.res! or .resources file( an then co$pile into asingle satellite asse$bly.
note ASP.NET AJAX enables you to create your o"n custo$ culture an your o"n culture na$e. +o"e#er
typically culture na$es are base on an 'S7 language coe that consists of t"o letters for a
language an t"o uppercase letters for a country or region. E!a$ples inclue es)MX
%Spanish Me!ico( es)*7 %Spanish *olu$bia( an fr)*A %4rench *anaa(. 4or a co$plete list of
culture na$es see the *ulture'nfo class o#er#ie".
N%)es /or $oc%li&ed E)edded Scri+t ,iles
The follo"ing na$ing con#ention is reco$$ene for locali5e script files that are e$bee as
resources2
scr#ptnamenoe%tens#onNdebu'ONUI culture #dent#5#erOresources
The ebug #ersion of a file na$e inclues F.ebugF in the na$e. The release #ersion oes not.
The follo"ing table sho"s e!a$ples of this na$ing con#ention. These e!a$ples sho" both a release
an ebug #ersion of an e$bee script file follo"e by the associate release an ebug #ersions
of resources for those script files.
Sa$ple.8sA release #ersion of a neutral)culture script file "hich is e$bee in the $ain asse$bly.
Sa$ple.ebug.8sA ebug #ersion of a neutral)culture script file "hich is also e$bee in the $ain
asse$bly.
49
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 50/70
Sa$ple.fr)49.resourcesA release #ersion of resources that are associate "ith the script file Sa$ple.8s locali5e for
a specific &' culture. These resources beco$e part of the satellite asse$bly.
Sa$ple.ebug.fr)49.resources-ebug)specific resources associate "ith the script file Sa$ple.ebug.8s locali5e for a
specific &' culture. These resources beco$e part of the satellite asse$bly that also inclues
the Sa$ple.fr)49.resources file.
This na$ing con#ention is not strictly require for script files that are e$bee in asse$blies or for
resource files. This is because the $apping bet"een the type generate for the resource an the
resource na$e is acco$plishe by using an asse$bly attribute.
$oc%li&in# "eu# Scri+t -esources
'f you are "orking in ebug $oe at run ti$e ASP.NET AJAX co$bines the release #ersion of
resources for script files "ith any aitional ebug resources. 't then sens the resulting
co$bination to the bro"ser. Therefore "hen you create resource files for ebug #ersions of scripts
you ha#e to efine only the na$e?#alue pairs that are not alreay inclue in the release script
resource files. 1y con#ention ebug #ersions of scripts an of script resources use the sa$e na$e
as their release counterpart but inclue F.ebugF after the script file na$e.
S+eci/yin# Asse)ly Attriutes /or $oc%li&ed Scri+ts %nd $oc%li&ed-esources Associ%ted with Scri+ts
To specify ho" resource files are $anage "hen an asse$bly is built you inclue attributes in the
Asse$bly'nfo file %Asse$bly'nfo.#b or Asse$bly'nfo.cs file(.
note 'n @isual Stuio the Asse$bly'nfo.#b file is in the $ Pro&ect noe of Solution E!plorer. 'f you o
not see any files in the $ Pro&ect noe in the Pro&ect $enu click (oE 9ll *#les. The
Asse$bly'nfo.cs file is in the Propert#es noe of Solution E!plorer.
'n ASP.NET you $ark resources for the application by using the Web9esourceAttribute class. To
e$be Ja#aScript files in an asse$bly you use this attribute to specify the .8s files as a Web
resource.
To inclue resource files for the e$bee Ja#aScript files you use the Script9esourceAttribute
class that is pro#ie by ASP.NET AJAX. This attribute ientifies the files specifically as resources for
the Ja#aScript files.
The follo"ing e!a$ple sho"s ho" to use asse$bly attributes to ientify e$bee scripts an their
associate script resources.
50
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 51/70
Ind#cates tat neutral 5allback resources are retr#eved 5rom te ma#n assembl$ named a#n9ssembl$<assembl$: eutral+esources2an'ua'e9ttr#bute."en-U("G Ult#mate+esource*allback2ocat#ona#n9ssembl$/>
De5#nes embedded scr#pts as )eb resources<assembl$:)eb+esource."(ample&s"G "te%t&avascr#pt"/>
<assembl$:)eb+esource."(ampledebu'&s"G "te%t&avascr#pt"/>
De5#nes te scr#pt resources 5or te scr#pts and te#r t$pes<assembl$:(cr#pt+esource."(ample&s"G "(ampleresources"G
"(ample+es"/><assembl$:(cr#pt+esource."(ampledebu'&s"G "(ampledebu'resources"G
"(ample+es"/> Ind#cates tat neutral 5allback resources are retr#eved 5rom te ma#n assembl$ named a#n9ssembl$
Nassembl$: eutral+esources2an'ua'e9ttr#bute."en-U("G Ult#mate+esource*allback2ocat#ona#n9ssembl$/O
De5#nes embedded scr#pts as )eb resourcesNassembl$:)eb+esource."(ample&s"G "te%t&avascr#pt"/ONassembl$:)eb+esource."(ampledebu'&s"G "te%t&avascr#pt"/O
De5#nes te scr#pt resources 5or te scr#pts and te#r t$pesNassembl$:(cr#pt+esource."(ample&s"G "(ampleresources"G
"(ample+es"/ONassembl$:(cr#pt+esource."(ampledebu'&s"G "(ampledebu'resources"G
"(ample+es"/O
'n this e!a$ple a $ain asse$bly na$e a#n9ssembl$ contains an e$bee release #ersion of a
client script file that is na$e Sa$ple.8s. The asse$bly also contains the corresponing ebug
#ersion na$e Sa$ple.ebug.8s. The .8s files are ientifie as resources by the
Web9esourceAttribute attribute.
The Neutral9esources,anguageAttribute asse$bly attribute is use to specify the $ain asse$bly as
the fallback culture. 4or $ore infor$ation see Neutral 9esources ,anguages for ,ocali5ation an theNeutral9esources,anguageAttribute class o#er#ie".
The resources use by the script files are efine by using the Script9esourceAttribute attribute.
The Sa$ple.resources an Sa$ple.ebug.resources files contain resource #alues for the Sa$ple.8s
an Sa$ple.ebug.8s files respecti#ely.
A type na$e Sa$ple.9es is generate for both the release an the ebug #ersion of the script
resources. This is the type that the Ja#aScript coe shoul use to access locali5e #alues. 4or both
release $oe an ebug $oe the buil process creates only a single type. 'n ebug $oe the
resources for the release #ersion are co$bine "ith the aitional resources for the ebug #ersion.
4or $ore infor$ation about ho" to create asse$bly)infor$ation files an the asse$bly $etaata
that is require for #ersione asse$blies see +o" to2 *reate @ersione Asse$blies for Preco$pile
Web Sites.
$oc%li&in# St%tic Scri+t ,iles %nd Their -esources
51
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 52/70
6ou can organi5e a script library as locali5e static script files %.8s files( on isk instea e$being
the script files in asse$blies. Page e#elopers can reference the script files through the
Script9eference*ollection class.
'n the static script file $oel there are no separate .res! or .resources files that can be
auto$atically $anage as resources for the Ja#aScript files. 'nstea there are only .8s files one fore#ery &' culture an locale co$bination. 'n effect each .8s file represents a locale)specific #ersion of
the co$plete Ja#aScript coe. A typical "ay to $anage locali5e script files in this $oel is to use
the sa$e Ja#aScript logic in each .8s file. As in the asse$bly)e$bee $oel the Ja#aScript coe
in#okes a type to retrie#e locali5e resource #alues. The ifference is that you $ust supply the type
that contains the locali5e #aluesit is not generate for you. 4or e!a$ple the .8s for each locale
can inclue both the application coe an a class that efines the fiels that hol locali5e #alues. 'n
each .8s file this class "oul contain #alues in a ifferent language.
note 'n the static script file $oel the application Ja#aScript coe in .8s files can get out of sync "ith the
coe in an e$bee Ja#aScript file. This is because each script file inclues a copy of the coe. Toa#oi #ersion control issues "ith uplicate coe you can $aintain a single copy of the Ja#aScript
source files an create locali5e resource types in separate files. 6ou can then generate the final
co$bine files uring your application3s buil process.
,ocali5e static script files are $appe to their &' culture by incluing the &' culture na$e as part
of the file na$e as "ith e$bee resources in an asse$bly. 4or e!a$ple an e$bee client
script file that is culturally neutral for 4rench "oul be na$e Sa$ple.fr.8s an a culture)specific
Ja#aScript resource for 4rench %*anaa( "oul be na$e Sa$ple.fr)*A.8s.
$oc%li&ed "eu# Scri+ts in the St%tic Scri+t ,ile 1odel
'n the static script file $oel locali5e resources that a script refers to are typically efine as a
type in a single .8s file. A ebug #ersion of a script file is organi5e in the sa$e "ay "ith both
locali5e release resources an aitional ebug resources efine as a type in a single file. -ebug
#ersions of scripts use the sa$e na$e as the corresponing release #ersion but inclue F.ebugF
after the na$e.
Usin# Scri+t1%n%#er to 1%n%#e Scri+ts
6ou can use the ScriptManager control to $anage static scripts that are locate in a central
irectory on isk. To o so put all #ersions of the script files in one foler incluing release an
ebug #ersions of all locali5e files. The follo"ing e!a$ple sho"s the layout of a irectory structure
for a static script file library2
(ampleamespace
1
52
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 53/70
(ample&s
(ampledebu'&s
(amplede-D3&s
(ampledebu'de-D3&s
(ample5r-*+&s
(ampledebu'5r-*+&s
'n this e!a$ple all the script files are in a foler that is na$e by using the script library #ersion
%D.0.0.0(. This #ersion)specific foler is in turn in a foler that is na$e after the library3s
na$espace. 7rgani5ing a script library "ithin folers by na$espace an #ersion can pro#ie so$e
#ersion control for your library an it can help you a#oi script)na$e collisions bet"een libraries. 't
also enables consu$ers of your library to ientify "hat library an library #ersion the files belong to.
Underst%ndin# the -ole o/ the Scri+t1%n%#er Control in $oc%li&%tion
The ScriptManager control pro#ies the follo"ing functionality for using locali5e scripts an script
resources2
← Enables you to efine "hich &' cultures are supporte "hich inclues custo$ &' cultures.
← 'nterprets the culture)specific asse$bly attribute an auto$atically etects the &' culture
of the bro"ser %if any( an then reas the locali5e or fallback scripts an resources fro$
the asse$bly. 'n ebug $oe it tries to loa a script resource that contains both the
appropriate &' culture na$e an the string F.ebugF in the file na$e such as
Sa$ple.ebug.fr)49.resources.
← :enerates &9,s that point to the appropriate scripts an to their locali5e resources. 4or
ae security it encrypts the &9,s.
← -eter$ines "hether a script or script resource "ill be co$presse base on a para$eter in
the generate &9,.
← As a ti$esta$p to the asse$bly that contains e$bee scripts so that the bro"ser oes
not inefinitely cache the scripts.
4or $ore infor$ation see the ScriptManager class o#er#ie".
53
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 55/70
Script9eference Pro#ies AP's for registering Ja#aScript files for use in a Web page either files that are
e$bee in an asse$bly or that are on isk.
Script9eference*ollection Pro#ies access to Script9eference ob8ects that represent client script files.
See Also
← ASP.NET Web Page 9esources 7#er#ie"
← *reating *usto$ ASP.NET AJAX Non)@isual *lient *o$ponents
← +o" to2 *reate 9esource 4iles for ASP.NET Web Sites
← +o" to2 *reate @ersione Asse$blies for Preco$pile Web Sites
← -yna$ically Assigning ASP.NET AJAX Script 9eferences
← ,ocali5ing ASP.NET Web Pages &sing 9esources
← 9esource 4ile :enerator %9esgen.e!e(
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
ASP.NET AJAX Client $i/e*Cycle Events
Introduction
A Microsoft ASP.NET AJAX page raises the sa$e ser#er life)cycle e#ents as an ASP.NET /.0 Web
page an also raises client life)cycle e#ents. The client e#ents enable you to custo$i5e the &' for
both postbacks an for asynchronous postbacks %partial)page upates(. The client e#ents also help
you $anage custo$ script co$ponents uring the lifeti$e of the page in the bro"ser.
The client e#ents are raise by classes in the Microsoft AJAX ,ibrary. These classes are auto$atically
instantiate "hen a page contains ASP.NET AJAX ser#er controls. The client classes pro#ie AP's
that enable you to bin to e#ents an to pro#ie hanlers for those e#ents. 1ecause the Microsoft
AJAX ,ibrary is bro"ser inepenent the coe you "rite for your hanlers "orks the sa$e in all
supporte bro"sers.
The key e#ent for initial requests %:ET requests( an synchronous postbacks is the loa e#ent of the
Application instance. When script in a loa e#ent hanler runs all scripts an co$ponents ha#e
been loae an are a#ailable. When partial)page renering "ith &patePanel controls is enable
the key client e#ents are the e#ents of the Page9equestManager class. These e#ents enable you to
hanle $any co$$on scenarios. These inclue the ability to cancel postbacks to gi#e preceence
to one postback o#er another an to ani$ate &patePanel controls "hen their content is refreshe.
*lient e#ents are useful "hether you are creating pages or "riting co$ponents. 'f you are a page
e#eloper you can pro#ie custo$ script that is calle "hen the page loas an unloas in the
bro"ser.
55
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 56/70
4or $ore infor$ation about the ser#er life)cycle e#ents see ASP.NET Page ,ife *ycle 7#er#ie".
Client Cl%sses
The t"o $ain Microsoft AJAX ,ibrary classes that raise e#ents uring the client life cycle of an
ASP.NET AJAX Web page are the Application an Page9equestManager classes.
The Application class is instantiate in the bro"ser "hen the page contains a ScriptManager control.
The Application class rese$bles the Page ser#er control "hich eri#es fro$ the *ontrol class but
pro#ies aitional functionality for raising ser#er e#ents. Si$ilarly the Application class eri#es
fro$ the Sys.*o$ponent class but raises client life)cycle e#ents that you can hanle.
'f a page contains a ScriptManager control an one or $ore &patePanel controls the page can
perfor$ partial)page upates %if partial)page renering is enable an supporte in the bro"ser(. 'n
that case an instance of the Page9equestManager class is auto$atically a#ailable in the bro"ser.
The Page9equestManager class raises client e#ents that are specific to asynchronous postbacks. 4or
etails about partial)page renering see Partial)Page 9enering 7#er#ie".
Addin# 0%ndlers /or Client Events
To a or re$o#e hanlers for e#ents raise by the Application an Page9equestManager classes
use the add_ e#entna$e an remove_ e#entna$e $ethos of those classes. The follo"ing e!a$ple
sho"s ho" to a a hanler na$e $2oad to the init e#ent of the Application ob8ect.
CS
($s9ppl#cat#onadd#n#t.$In#t/05unct#on $In#t.sender/ 67($s9pppl#cat#onremove#n#t.$In#t/0
VB
($s9ppl#cat#onadd#n#t.$In#t/05unct#on $In#t.sender/ 67($s9pppl#cat#onremove#n#t.$In#t/0
note This e!a$ple sho"s 8ust the synta! of the add_ e#entna$e an remove_ e#entna$e $ethos.
-etails about "hat you can o "ith specific e#ents are pro#ie later in this topic.
0%ndlin# the A++lic%tion $o%d %nd Unlo%d Events
To hanle the loa an unloa e#ents of the Application ob8ect you o not ha#e to e!plicitly bin a
hanler to the e#ent. 'nstea you can create functions that use the reser#e na$es pa'e2oad an
56
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 57/70
pa'eUnload. The follo"ing e!a$ple sho"s ho" to a a hanler for the loa e#ent of the
Application ob8ect by using this approach.
CS
5unct#on pa'e2oad.senderG ar's/ 6
7
VB
5unct#on pa'e2oad.senderG ar's/ 67
Events /or Other Client Cl%sses
This topic escribes only the e#ents that are raise by the Application an Page9equestManager
classes. The Microsoft AJAX ,ibrary also contains classes for aing clearing an re$o#ing
hanlers for -7M ele$ent e#ents. These classes inclue the follo"ing2
← The Sys.&'.-o$E#ent.a+anler $etho or the shortcut Ga+anler.
← The Sys.&'.-o$E#ent.clear+anlers $etho or the shortcut Gclear+anlers.
← The Sys.&'.-o$E#ent.re$o#e+anler $etho or the shortcut Gre$o#e+anler.
E#ents raise by -7M ele$ents are not iscusse in this topic.
Client Events o/ the A++lic%tion %nd P%#e-e2uest1%n%#er Cl%sses
The follo"ing table lists client e#ents of the Application an Page9equestManager classes that you
can hanle in AJAX ASP.NET)enable pages. The orer in "hich the e#ents are raise is escribe
later in this topic.
Event Description
init E#ent 9aise after all scripts ha#e been loae but before any ob8ects are create.
'f you are "riting a co$ponent the init e#ent gi#es you a point in the life
cycle to a your co$ponent to the page. The co$ponent can then be use
by other co$ponents or by script later in the page life cycle. 'f you are a
page e#eloper you shoul use the loa e#ent instea of the init e#ent for
$ost scenarios.
The init e#ent is raise only one ti$e "hen the page is first renere.
Subsequent partial)page upates o not raise the init e#ent.
57
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 58/70
loa E#ent 9aise after all scripts ha#e been loae an all ob8ects in the application
that are create by using Gcreate are initiali5e. The loa e#ent is raise for
all postbacks to the ser#er "hich inclues asynchronous postbacks.
'f you are a page e#eloper you can create a function that has the na$e
pa'e2oad "hich auto$atically pro#ies a hanler for the loa e#ent. The
pa'e2oad hanler is calle after any hanlers that ha#e been ae to the
loa e#ent by the aHloa $etho.
The loa e#ent takes an eventargs para$eter "hich is an
Sys.Application,oaE#entArgs ob8ect. 6ou can use the e#ent argu$ents to
eter$ine "hether the page is being refreshe as a result of a partial)page
upate an "hat co$ponents "ere create since the pre#ious loa e#ent "as
raise.
unloa E#ent 9aise before all ob8ects are ispose an before the bro"ser "ino"3s
windowunload e#ent occurs.
'f you are a page e#eloper you can create a function that has the na$e
pa'eUnload "hich auto$atically pro#ies a hanler for the unloa e#ent.
The pa'eUnload e#ent is calle 8ust before the page is unloae fro$ the
bro"ser. -uring this e#ent you shoul free any resources that your coe is
holing.
property*hange
E#ent
Potentially raise "hen a property of a co$ponent changes. The Application
ob8ect inherits this e#ent fro$ the *o$ponent class. This e#ent is raise only
if a co$ponent e#eloper has calle the Sys.*o$ponent.raiseProperty*hange
$etho in a property set accessor. 4or $ore infor$ation see -efining
*usto$ *o$ponent Properties an 9aising Property*hange E#ents.
The property*hange e#ent takes an eventargs para$eter "hich is a
Sys.application,oaE#entArgs ob8ect.
isposing E#ent 9aise "hen the Application instance is ispose. The Application ob8ect
inherits this e#ent fro$ the *o$ponent class.
initiali5e9equest
E#ent
9aise before an asynchronous request starts. 6ou can use this e#ent to
cancel a postback such as to gi#e preceence to another asynchronous
postback.
The initiali5e9equest e#ent takes an eventargs para$eter "hich is a
Sys.Web4or$s.'nitiali5e9equestE#entArgs ob8ect. This ob8ect $akes a#ailable
the ele$ent that cause the postback an the unerlying request ob8ect.
'nitiali5e9equestE#entArgs also e!poses a cancel property. 'f you set cancel
to true the ne" postback is cancele.
begin9equest
E#ent
9aise before an asynchronous postback starts an the postback is sent to
the ser#er. 'f there is a postback alreay processing it is stoppe %by using
the abortPost1ack $etho(. 6ou can use this e#ent to set request heaers or
58
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 59/70
to begin an ani$ation on the page to inicate that the request is in process.
The begin9equest e#ent takes an eventargs para$eter "hich is a
Sys.Web4or$s.1egin9equestE#entArgs ob8ect. This ob8ect $akes a#ailable
the ele$ent that cause the postback an the unerlying request ob8ect.
page,oaing
E#ent
9aise after the response fro$ the ser#er to an asynchronous postback is
recei#e but before any content on the page is upate. 6ou can use this
e#ent to pro#ie a custo$ transition effect for upate content.
The page,oaing e#ent takes an eventargs para$eter "hich is an
Sys.Web4or$s.Page,oaingE#entArgs ob8ect. This ob8ect $akes a#ailable
infor$ation about "hat panels "ill be elete an upate as a result of the
$ost recent asynchronous postback.
page,oae
E#ent
9aise after all content on the page is refreshe as a result of either a
synchronous or an asynchronous postback. 4or synchronous postbacks
panels can only be create but for asynchronous postbacks panels can be
both create an upate. 6ou can use this e#ent to $anage a custo$
transition effect for upate content.
The page,oae e#ent takes an eventargs para$eter "hich is an
Sys.Web4or$s.Page,oaeE#entArgs ob8ect. This ob8ect $akes a#ailable
infor$ation about "hich panels "ere upate an create in the $ost recent
postback.
en9equest E#ent 9aise after the response for an asynchronous postback is processe an the
page is upate or uring the processing of the response if there is an error.
'f an error occurs the page is not upate. &se this e#ent to pro#ie
custo$i5e error notification to users or to log errors.
The en9equest e#ent takes an eventargs para$eter "hich is a
Sys.Web4or$s.En9equestE#entArgs ob8ect. This ob8ect $akes a#ailable
infor$ation about errors that ha#e occurre an "hether the error "as
hanle. 't also $akes a#ailable the response ob8ect.
Event Order E!%)+le
The follo"ing e!a$ple sho"s the client e#ents that are raise on a page that inclues t"o
&patePanel controls one neste insie the other. 6ou "ill notice a ifference bet"een clicking the
button in the parent panel an clicking the button in the neste panel. The button in the parentpanel causes the parent panel to be upate an the neste panel to be elete an recreate. The
button in the neste panel causes 8ust the neste panel to be upate.
9un @ie"
Event Order /or Co))on Scen%rios
59
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 60/70
The orer of e#ents epens on "hat controls are use on the page an "hat type of request is
$ae %initial request postback or asynchronous postback(. This section escribes the orer of
e#ents for se#eral co$$on scenarios.
Initi%l -e2uest-uring the initial request for the page a li$ite nu$ber of client e#ents are raise. Assu$e the
follo"ing scenario for the initial request2
← The page contains a ScriptManager control an the control3s SupportsPartial9enering an
EnablePartial9enering property are both true.
← The request is a :ET request.
← A response fro$ the ser#er is returne successfully.
The follo"ing client e#ents occur in this orer2
D. The initial request is sent to the ser#er.
/. The response is recei#e by the client.
C. The Application instance raises the init e#ent.
I. The Application instance raises the loa e#ent.
The init e#ent of the Application instance is raise only one ti$e for the life of the page in the
bro"ser. 't is not raise for subsequent asynchronous postbacks. -uring an initial request no
Page9equestManager e#ents are raise.
Asynchronous Post%c(
An asynchronous postback sens so$e page ata to the ser#er recei#es a response an upates a
part of the page. Assu$e the follo"ing scenario for an asynchronous postback2
← The page contains a ScriptManager control an the control3s SupportsPartial9enering anEnablePartial9enering properties are both true.
← The page contains an &patePanel control an the control3s *hilrenAsTriggers property is
true.
← A button insie the &patePanel control initiates an asynchronous postback.
60
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 61/70
← A response fro$ the ser#er is returne successfully.
The follo"ing client e#ents occur in this orer2
D. The button insie the &patePanel is clicke "hich initiates an asynchronous postback.
/. The Page9equestManager instance raises the initiali5e9equest e#ent.
C. The Page9equestManager instance raises the begin9equest e#ent.
I. The request is sent to the ser#er.
=. The response is recei#e by the client.
B. The Page9equestManager instance raises the page,oaing e#ent.
>. The Page9equestManager instance raises the page,oae e#ent.
. The Application instance raises the loa e#ent.
K. The Page9equestManager instance raises the en9equest e#ent.
4or $ore infor$ation see Working "ith Page9equestManager E#ents.
Note that the loa e#ent of the Application instance is raise after the
Page9equestManagerpage,oae e#ent an before its en9equest e#ent.
1ulti+le Asynchronous Post%c(s
Multiple asynchronous postbacks can occur "hen users initiate a ne" request before a pre#iously
initiate request has finishe processing on the ser#er or in the bro"ser. Assu$e the follo"ing
scenario for $ultiple asynchronous postbacks2
← The page contains a ScriptManager control an the control3s SupportsPartial9enering an
EnablePartial9enering property are both true.
← The page contains an &patePanel control.
← A button insie the &patePanel control that initiates an asynchronous postback is clicke
t"o ti$es. The secon click occurs "hile the ser#er is processing the request initiate by
the first click.
← A response to the first request is returne successfully fro$ the ser#er.
61
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 62/70
The follo"ing client e#ents occur in this orer2
D. A button insie the &patePanel is clicke "hich initiates an asynchronous postback.
/. The Page9equestManager instance raises the initiali5e9equest e#ent.
C. The Page9equestManager instance raises the begin9equest e#ent.
I. The request is sent to the ser#er.
=. The button is clicke again "hich initiates a secon asynchronous postback.
B. The Page9equestManager instance raises the initiali5e9equest e#ent for the secon button
click.
>. The Page9equestManager instance raises the en9equest e#ent for the first button click.
. The Page9equestManager instance raises the begin9equest e#ent for the secon button
click.
K. The request initiate by the secon click is sent to the ser#er.
D0. The response is recei#e for the secon click.
DD. The Page9equestManager instance raises the page,oaing e#ent.
D/. The Page9equestManager instance raises the page,oae e#ent.
DC. The Application instance raises the loa e#ent.
DI. The Page9equestManager instance raises the en9equest e#ent.
The efault beha#ior of asynchronous postbacks is that the $ost recent asynchronous postback
takes preceence. 'f t"o asynchronous postbacks occur in sequence an if the first postback is still
being processe in the bro"ser the first postback is cancele. 'f the first postback has been sent to
the ser#er the ser#er processes the secon request "hen it arri#es an oes not return the first
request. 4or infor$ation about ho" to gi#e preceence to a specific asynchronous postback see
:i#ing Preceence to a Specific Asynchronous Postback.
rowsin# Aw%y /ro) % P%#e
When the user bro"ses a"ay fro$ a page the current page is unloae fro$ the bro"ser an you
can hanle the unloa e#ent to free resources. Assu$e the follo"ing scenario for bro"sing a"ay
fro$ a page2
62
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 63/70
← The page contains a ScriptManager control an the control3s SupportsPartial9enering an
EnablePartial9enering property are both true.
← The target page e!ists.
The follo"ing client e#ents are raise in this orer2
D. The request for ne" page is initiate.
/. The response for the ne" page is recei#e by the bro"ser.
C. The Application instance raises the unloa e#ent.
I. The ne" page is isplaye.
'f there is an error in the request for the ne" page the unloa e#ent is still raise but the ne"page is not isplaye.
See Also
← ASP.NET Page ,ife *ycle 7#er#ie"
← -efining *usto$ *o$ponent Properties an 9aising Property*hange E#ents
← Working "ith Page9equestManager E#ents
← *reating *usto$ *lient E#ents
*opyright < /00= ) /00> Microsoft *orporation. All rights reser#e.
ASP.NET AJAX "eu##in# %nd Tr%cin# Overview
Introduction
Microsoft ASP.NET AJAX applications contain a $i! of ser#er coe an client coe. The bro"ser can
also request aitional ata asynchronously. This can $ake ebugging AJAX)enable Web
applications challenging. This o#er#ie" iscusses so$e techniques an tools that can help
you ebug your coe $ore easily.
note With the e!ception of @isual Stuio an 'nternet E!plorer the progra$s $entione in this topic are
thir)party tools an are not supporte by Microsoft. Please see the tool3s Web site for licensing an
support infor$ation.
This topic contains2
63
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 65/70
Con3#urin# the A++lic%tion /or "eu##in#
To enable ebugging a a compilation ele$ent to the site3s root Web.config file an then set its
debug attribute to true. 4or $ore infor$ation see co$pilation Ele$ent %ASP.NET Settings Sche$a(.
The follo"ing e!a$ple sho"s a section fro$ a Web.config file that has the debug attribute set.
<con5#'urat#on> <s$stemEeb> <comp#lat#on debu'="true"> <!-- etc --> <comp#lat#on> <s$stemEeb><con5#'urat#on>
When ebugging is enable ASP.NET AJAX uses a ebug #ersion of the client libraries.
Settin# the A++lic%tion /ro) "eu# to -ele%se 1ode /or "e+loy)ent
When you eploy a release #ersion of an AJAX)enable ASP.NET application $ake sure that it is set
to release $oe. This $akes sure that ASP.NET uses the perfor$ance)opti$i5e release #ersion of
the ASP.NET AJAX libraries. 'f you ha#e create ebug an release #ersions of your custo$ scripts
an script resources ASP.NET also uses the release #ersions. To set the application to release $oe
o the follo"ing2
← 'n the Web.config file if the compilation ele$ent contains a debug attribute $ake sure
that the debug attribute is set to false.
← Make sure that any Web page that contains a ScriptManager control has its ScriptMoe
property set to !elease.
The debug attribute of the L Page irecti#e oes not affect ASP.NET AJAX applications. The
ScriptManager control uses only the settings in the Web.config file an in its
's-ebuggingEnable an ScriptMode properties to eter$ine "hether to rener ebug scripts.
Tr%cin# on the Server
'f you are using tracing on the ser#er to ebug Web pages that ha#e partial)page renering
enable you shoul use the trace #ie"er %Trace.a!( to isplay trace output. 6ou can appen trace
output to the en of the page an it is isplaye the first ti$e the page is renere. +o"e#er the
trace isplay is not upate as a result of asynchronous postbacks because only the contents of
&patePanel controls that ha#e to be refreshe "ill change. 4or $ore infor$ation about ho" to use
the trace #ie"er see ASP.NET Tracing.
note
65
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 66/70
Partial)page renering is enable "hen the page contains a ScriptManager control "ith its
EnablePartial9enering property set to true. The page $ust also contain one or $ore &patePanel
controls.
"eu# 0el+er Cl%ss
Microsoft AJAX ,ibrary pro#ies the Sys.-ebug class for ebugging client applications. 1y calling
$ethos of the Sys.-ebug class you can isplay ob8ects in reaable for$ at the en of the page
sho" trace $essages use assertions an break into the ebugger.
'f you are using @isual Stuio an 'nternet E!plorer you can attach the @isual Stuio ebugger to
the bro"ser an #ie" ebugger trace $essages in the utput "ino". 'f you are not using @isual
Stuio you can #ie" ebugger trace $essages in 'nternet E!plorer by creating a te"tarea ele$ent
on the page an setting its '- to TraceConsole. 'n Mo5illa 4irefo! you can #ie" ebugger trace
$essages by using tools that are a#ailable as e!tensions. The Apple Safari an 7pera bro"sers
isplay trace $essages in their respecti#e ebugging consoles.
The follo"ing table lists the $ethos of the Sys.-ebug class.
Sys.-ebug.assert%conition $essage isplay*aller( *hecks for a conition an if the conition is false isplays a $essage an pro$pts the
user to break into the ebugger.
Sys.-ebug.clearTrace%( *lears all trace $essages fro$ the TraceConsolete"tarea ele$ent.
Sys.-ebug.trace-u$p%ob8ect na$e( -u$ps an ob8ect to the ebugger console an to the TraceConsolete"tarea ele$ent if
a#ailable.
Sys.-ebug.fail%$essage( -isplays a $essage in the ebugger3s output "ino" an breaks into the ebugger.
Sys.-ebug.trace%te!t( Appens a te!t line to the ebugger console an to the TraceConsolete"tarea ele$ent if
a#ailable.
The follo"ing e!a$ple sho"s ho" to call $ethos of the Sys.-ebug class2
9un @ie"
Con3#urin# Internet E!+lorer /or "eu##in#
1y efault 'nternet E!plorer ignores proble$s it encounters in Ja#aScript. 6ou can enable
ebugging by using the follo"ing proceure.
66
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 67/70
To en%le deu##in# in Internet E!+lorer
D. 'n the Tools $enu click Internet pt#ons.
/. 'n the 9dvanced tab clear the D#sable (cr#pt Debu''#n' .Internet 3%plorer/ check
bo! an the D#sable (cr#pt Debu''#n' .ter/ check bo!.
C. Select the D#spla$ a not#5#cat#on about ever$ scr#pt error check bo!.
I. To turn off FfrienlyF error $essages clear the (oE 5r#endl$ 4TTP error messa'es
check bo!.
'f FfrienlyF error $essage are enable an if an +TTP =00 error response fro$ the ser#er is less
than =DC bytes long 'nternet E!plorer $asks the content. 'n place of the error infor$ation
'nternet E!plorer isplays a $essage that is $eant for en users not e#elopers.
Att%chin# the 4isu%l Studio "eu##er to Internet E!+lorer
67
8/10/2019 ASP Dot Net Ajax
http://slidepdf.com/reader/full/asp-dot-net-ajax 68/70
To ebug client script you $ust attach a ebugger to 'nternet E!plorer. 'n @isual Stuio if you start
your application for ebugging %by pressing 4= or using the (tart Debu''#n' co$$an in the
Debu' $enu( the ebugger is attache auto$atically.
6ou can also attach the @isual Stuio ebugger to 'nternet E!plorer "hen the application is alreay
running. To o so in the Debu' $enu click 9ttac to Process. 'n the 9ttac to Process
ialog bo! select the instance of 'nternet E!plorer %ie!plore.e!e( that you "ant to attach the
ebugger to.
note 'f 'nternet E!plorer is configure for ebugging the T$pe colu$n for the rele#ant instance of
'nternet E!plorer isplays (cr#ptG %QK. 'f you see only %QK in the T$pe colu$n $ake sure that
'nternet E!plorer is configure for ebugging.
'f 'nternet E!plorer encounters a script error an is configure for script ebugging but it is not
currently attache to a ebugger the bro"ser pro$pts you to select a ebugger. 6ou can either
continue "ithout ebugging or attach a ebugger an step through the coe.
Internet E!+lorer 5nown "eu##in# Issues %nd Wor(%rounds
When you ebug ASP.NET AJAX applications that use 'nternet E!plorer be a"are of the follo"ing
issues an "orkarouns2
← After the @isual Stuio ebugger is attache to 'nternet E!plorer you can see a list of the
scripts that are being ebugge in the @isual Stuio (cr#pt 3%plorer "ino". %To isplay
this "ino" in the Debu' $enu click )#ndoEs an then click (cr#pt 3%plorer(. The
ASP.NET AJAX client library "ill appear as a resource starting "ith
(cr#pt+esourcea%dR "hich the ser#er generates yna$ically fro$ the ASP.NET
AJAX asse$bly. A kno"n bug in @isual Stuio $ight pre#ent you fro$ opening the file. 'f
@isual Stuio isplays an error $essage to that effect or if it ignores clicks on the file
na$e close all script files that are open. 6ou can then open the page an select the script
files that you "ant to ebug.
← 6ou cannot set breakpoints in Ja#aScript coe insie script ele$ents in an ASP.NET page
until after the ebugger has steppe into Ja#aScript coe on that page. To "ork aroun this
issue set the breakpoint on the function that the call co$es fro$ an step into the coe
on the ASP.NET Web page. After the ebugger has stoppe on a line of Ja#aScript coe in
the page you can set breakpoints as usual. Another "ay to ha#e the ebugger recogni5e
scripts in an ASP.NET page is to create a $etho in the ASP.NET page file that calls the
Sys.-ebug.fail $etho. When you call this $etho the ebugger "ill stop on the call to
Sys.-ebug.fail an let you set breakpoints else"here. A thir alternati#e is to put all your
custo$ coe in e!ternal Ja#aScript files.
68