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....


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, June 03, 2008 3:22 PM | in C# .NET

Comments

No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  


Please add 8 and 7 and type the answer here: