Call JavaScript Function

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,
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

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

Steve Kershaw

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
 
K

Kevin Spencer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top