[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1411
  • Last Modified:

onload event of an asp.net 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 ;

   }

???
0
bozworthy
Asked:
bozworthy
  • 2
  • 2
1 Solution
 
nouloukCommented:
Hi bozworthy,

Where is  the window.onload = onLoad() event ?
0
 
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()
// ]]>
</script>

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?


0
 
nouloukCommented:
It works fine for me.
I put the script inside Head tags. What about you ?
0
 
bozworthyAuthor Commented:
I threw <h1>  </h1> around the script and it worked.  Thanks!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now