onload event of an content page

I've successfully included some javascript in a content page for the interaction of radio buttons and a dropdownbox when each is selected/clicked.  Now I want to perform some functions when the content page loads but I'm having trouble.  

I tried this in my asp Page_Load event but it's not firing:
       If Not Page.ClientScript.IsClientScriptBlockRegistered(t, "onLoad") Then
            Me.ClientScript.RegisterClientScriptInclude("onLoad", "~/scripts/JScript.js")
        End If

Here are the contents of the above script file:
  function onLoad() {
       alert('hitting load of counts');
       document.getElementById('selMonth').options[+document.getElementById('txtHiddenMonth').value].selected = true ;


Who is Participating?
nouloukConnect With a Mentor Commented:
It works fine for me.
I put the script inside Head tags. What about you ?
Hi bozworthy,

Where is  the window.onload = onLoad() event ?
bozworthyAuthor Commented:
When I select 'window' on the left dropdown and 'onload' event from the right, it places the following two segments of code in my file:

<script language="javascript" type="text/javascript" for="window" event="onload">
// <!CDATA[
return window_onload()
// ]]>

function window_onload() {


I'm getting the design time error "Element 'for' is not a valid attribute of element 'script'.  Same thing for 'event'.    The script blows up at run time.  What's wrong?

bozworthyAuthor Commented:
I threw <h1>  </h1> around the script and it worked.  Thanks!!
All Courses

From novice to tech pro — start learning today.