Call JavaScript Function

  • Thread starter Thread starter Mike McIntyre
  • Start date Start date
M

Mike McIntyre

What event can be used to call a JavaScript function when the page loads AND
when it receives a response from the web server?

Thanks,
 
The body's onload event is raised when the page has been fully loaded.
I'm not sure what you mean about "when it receives a response from the web
server".
 
The body's onload event is raised when the page has been fully loaded.
I'm not sure what you mean about "when it receives a response from the web
server".

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsiderhttp://SteveOrr.net






- Show quoted text -

In the Page_Load method use:

string strScript = @"<script language=""javascript"">
window.alert(""put your script here""); </script>";
Page.ClientScript.RegisterStartupScript(typeof(Page), "ScriptName",
strScript);

That should do it.

Steve
 
The Page_Load event fires whenever the Page is requested. I believe that by
"the page gets a response from the server" you are referring to a PostBack.
The Page doesn't get a response from the server. The browser does, every
time it requests a Page. But the Page_Load event fires with each response,
not just the initial (non-PostBack) response.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Back
Top