Solved

onload event of an asp.net content page

Posted on 2006-12-01
4
1,401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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