Solved

onload event of an asp.net content page

Posted on 2006-12-01
4
1,389 Views
Last Modified: 2010-05-18
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
Comment
Question by:bozworthy
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:noulouk
ID: 18057530
Hi bozworthy,

Where is  the window.onload = onLoad() event ?
0
 
LVL 1

Author Comment

by:bozworthy
ID: 18068801
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
 
LVL 9

Accepted Solution

by:
noulouk earned 250 total points
ID: 18069928
It works fine for me.
I put the script inside Head tags. What about you ?
0
 
LVL 1

Author Comment

by:bozworthy
ID: 18070432
I threw <h1>  </h1> around the script and it worked.  Thanks!!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now