Jakew
Consulting, hacking, and motorcycles

MS Ajax 101 Client Side

Thursday, 22 March 2007 00:21 by jakew

Why do you always drop a ScriptManager control on your page or control?

Because this is the first indication to your application that MS Ajax is going to come into play. When the form containing hte ScriptManager loads, the script manager instantiates an Application object which exposes some events that run through a full life cycle similar to a regular asp.net page.

The events exposed by the Application object are:

1. init event

2. load event

3. unload event

 

To capture these in javascript add the following AFTER the SCRIPTMANAGER tags

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="False" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />

<script type="text/javascript" language="javascript">

var app = Sys.Application;

app.add_init(InitHandler); //the InitHandler is just the name of my method that will be used.

app.add_load(LoadHandler);

app.add_unload(UnLoadHandler);

function InitHandler(sender, args)

{

 

}

 

function LoadHandler(sender, args)

{

 

}

 

function UnLoadHandler(sender, args)

{

 

}

</script>

 

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed