What time is it on the server?


label1 [updated by button click]:
label2 [set by window.setTimeout, but updated by the Trigger (every 5sec)]:
label3 [updated by window.setInterval (every sec)]:
label4 [updated by UpdatePanel,Trigger,Timer (every 5sec)]:

Page features:
ScriptManager > Services > ServiceReference - this allows us to call a server-side web service through the client.
UpdatePanel > Triggers > AsyncPostBackTrigger - this causes the ContentTemplate items to be updated asynchly by the Control that is linked to the Trigger, which happens to be a Timer control. Thus, the Timer control calls Timer1_Tick at every 5sec. interval, which updates Label4 in server-side code, then the Trigger is called to update the UI to reflect the new value of Label4.

When using the AJAX client library, client-side functions, pageLoad & pageUnload are available. On this page, pageLoad calls window.setTimeout which calls our Web service immediately and updates Label2 through the client-side onMethodCompleted function with the result; pageLoad also calls window.setInterval which calls our Web service every second and updates Label3 through the client-side onMethodCompleted function. The onMethodCompleted client-side function uses the $get() shortcut to update whichever label is passed in. There is also a button, which when clicked, calls a client-side function that calls the Web service and updates Label1 through the client-side onMethodCompleted.