473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Script in body

Joy
Hi all

I know that I can use the following code to add some script-code to a button
button.Attributes("onclick") = myscript
I like to do the same for the page itself as ("onload") = "myjavascriptfunction();
Which element do I need to use? me.Attributes("onload") is not possible

Thanks a lo

Joy
Nov 18 '05 #1
2 1279
Page.RegisterStartupScript()

http://msdn.microsoft.com/library/de...criptTopic.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Joy" <an*******@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
Hi all,

I know that I can use the following code to add some script-code to a button: button.Attributes("onclick") = myscript.
I like to do the same for the page itself as ("onload") = "myjavascriptfunction();" Which element do I need to use? me.Attributes("onload") is not possible.

Thanks a lot

Joy

Nov 18 '05 #2
Try this:

1. Give the <body> tag an id, and make it run as a htmlcontrol

<body id="myBody" runat="server">

2. In your code-behind, create a reference to the body object, and attach the
function you need to the "onload" event.

Protected WithEvents myBody As
System.Web.UI.HtmlControls.HtmlContainerControl

body.Attributes("onload") = "myjavascriptfunction();"

Tommy,

Joy <an*******@discussions.microsoft.com> wrote in message news:<6D**********************************@microso ft.com>...
Hi all,

I know that I can use the following code to add some script-code to a button:
button.Attributes("onclick") = myscript.
I like to do the same for the page itself as ("onload") = "myjavascriptfunction();"
Which element do I need to use? me.Attributes("onload") is not possible.

Thanks a lot

Joy

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dennis | last post by:
This may be easy for most but I can't get this thing to work. I believe I followed all the instructions but when I click on the link no window opens just the default IE page cannot display. Here is...
8
by: Jakej | last post by:
I've been using a javascript in an html file for a banner slider, and it works as desired. But I'd like to use it on more than one page and it would be great if I could transfer the code to a .js...
2
by: Earl Teigrob | last post by:
I am trying to build a custom control to wrap my smart navigation implimention (not microsofts 'cause it has problems) The follow code works fine when the onclick and onload events are defined in...
3
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None...
2
by: bilaribilari | last post by:
Hi all, I am using Tidy (C) for parsing html pages. I encountered a page that has some script as follows: <script> .... var abc = "<script>some stuff here</" + "script>"; .... </script>
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
14
RMWChaos
by: RMWChaos | last post by:
Firebug is reporting "too much recursion" when I attempt to create a child element in a parent that doesn't exist yet. The script should automatically create the missing parent before going on to...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
1
by: rfr | last post by:
Apparently the Transitional Doctype kills this script because the script does not make proper use of units like "px". It works well without a doctype statement. But once someone adds a...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.