Doing <body onload="something()"> in ASP.Net

  • Thread starter Thread starter Bob Delaney
  • Start date Start date
B

Bob Delaney

I use some older JavaScript in classic ASP pages. I'm trying to migrate
these pages to ASP.Net. I am using a Master Page.
To operate a slide show routine written in JavaScript, I have, in the
classic ASP pages, used an onload event, like this:
<body onload=routineName()>
Is there some way to do this using a Master Page in ASP.Net?
Bob Delaney
 
The body tag is in the master page, not the 'content' pages, so you can put
it in there like before. Using <body onload="dothis()"> is not really
outdated in ASP.NET.

BTW I recommend looking at www.asp.net and click on Learn, to learn about
ASP.NET, and get a good Wrox book on the subject.

HTH,
Justin Dutoit
 
Bob said:
I use some older JavaScript in classic ASP pages. I'm trying to
migrate these pages to ASP.Net. I am using a Master Page.
To operate a slide show routine written in JavaScript, I have, in
the classic ASP pages, used an onload event, like this:
<body onload=routineName()>
Is there some way to do this using a Master Page in ASP.Net?
Bob Delaney

Presumably you're wanting to do something different in each page, so rather
than using onload in the <body> tag, you can add the function with a bit of
JavaScript:

<script type="text/javascript">
//<![CDATA[
function doSomething() {
/* do something */
};
window.onload = doSomething;
//]]>
</script>

HTH

Andrew
 
Back
Top