Solved

onload event of an asp.net content page

Posted on 2006-12-01
4
1,405 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

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!

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

729 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