Link to home
Start Free TrialLog in
Avatar of MattCoatney
MattCoatney

asked on

Javascript onload

I have a JS fun in a page that I need to run when the page loads. I can't put it in the body tag in the Master because it is only being used for one page. I tried usng an input text onload event to load the fun but it doesn't seem to work.

Ideas?
ASKER CERTIFIED SOLUTION
Avatar of mikeutt
mikeutt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Banzai10
Banzai10

An alternative to you is call

ClientScript.RegisterStartupScript

it is the new version of

ClientScript.IsStartupScriptRegistered

an example of how to use it is:

ClientScript.RegisterStartupScript( typeof(Page), "myrest", "<script>alert('Hello');</script>");
Ops I'm sorry, I forgot to tell you that ASP.NET has a function

to know if this scripts is already registered,

ClientScript.IsStartupScriptRegistered(string),

in my example you can use it like this,

if(!ClientScript.IsStartupScriptRegistered("mytest"))
  ClientScript.RegisterStartupScript( typeof(Page), "mytest", "<script>alert('Hello');</script>");

Regards,

Felipe Lopes
Avatar of MattCoatney

ASKER

Appreciate both of your responses.
Ok,

I am thankful to be able to help you,

but if my question was useful to you why don't you split the points =D.

Regards,
Felipe Lopes