Having just created a Google Map server control I spent some time trying to register the relevant unload scripts that the Google API demands. However there was no easy way to get access to the body tag, and I certainly didn't want to have to edit the body tag, adding runat="server" as that would ruin my nicely "wrapped" control, I simply want a developer to drag it out of their Visual Studio Toolbox and it work...
So after some thought I tried the following, which worked a treat:
//Now we need to add the google maps
//ONUNLOAD JavaScript function (it its not be added already)
if (!Page.ClientScript.IsStartupScriptRegistered(
typeof(MyControl), "GoogleMapUnload"))
{
Page.ClientScript.RegisterStartupScript(
typeof(MyControl),
"GoogleMapUnload",
"window.onunload = function () { GUnload(); };",
true);
}
So simply replace the GUnload(); with your own custom JavaScript - you get the idea....