473,396 Members | 1,834 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.

Add attribute to Body

How do I add an onload attribute to the body of webpage dynamically?
Nov 18 '05 #1
2 5259
Dan
Give the body tag an ID and Runat="server" property in your ASPX:

<body id="bodyHomePage" Runat="Server">

And then in your Page_Load do something like this:

bodyHomePage.Attributes.Add("onLoad", "alert('Welcome visitor')")

Dan
"Roger" <so*****@microsoft.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
How do I add an onload attribute to the body of webpage dynamically?

Nov 18 '05 #2
thanks

"Dan" <da*@dontspam.com> wrote in message
news:OQ*************@TK2MSFTNGP12.phx.gbl...
Give the body tag an ID and Runat="server" property in your ASPX:

<body id="bodyHomePage" Runat="Server">

And then in your Page_Load do something like this:

bodyHomePage.Attributes.Add("onLoad", "alert('Welcome visitor')")

Dan
"Roger" <so*****@microsoft.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
How do I add an onload attribute to the body of webpage dynamically?


Nov 18 '05 #3

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

Similar topics

0
by: Matthew Simoneau | last post by:
I'm trying to figure out how to HTML encode shift_jis text and put it into an attribute. Starting with this XML-file with characters encoded in shift_jis <?xml version="1.0"...
1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
3
by: pantagruel | last post by:
The following does not work in firefox: <script defer="defer"> var x=document.getElementsByName("repositoryNamespace") alert(x.length + " elements!")
1
by: Chris Millar | last post by:
wondered if anyone could help me - i'm trying to control the value of an attribute of the BODY tag on a page. So i've got: <html> <body test="colin"> <form ...... ** content ** </form>...
6
by: tshad | last post by:
Is there a way during Page_Load to change or add an attribute to the Body tag? I want to be able to change the onLoad body attribute to do a focus on one of my text boxes, such as: ...
4
by: dkacher | last post by:
Hello - I'm looking for a way to retain newlines when using XSL to copy the content of an XML attribute. I have this XML input: <?xml version="1.0"?> <A > <B x = "stuff" y = "line 1 line 2"...
9
by: gimme_this_gimme_that | last post by:
I have a page with the following HTML: <body id=""> What is the Javascript that changes the value of id to "HOME" ? I'd sort of like to use document.getElementById but the value of id is...
0
by: xirowei | last post by:
I try to search information from many websites, but what i can found is they only demonstrate the example with ONE ATTRIBUTE in a Cookie only. What i want is how to set more than 1 attribute in a...
3
by: Mike | last post by:
Hello, I'm trying the following code: function MoveTeam(id){ This works-gets the value of the element var x=document.getElementById(id).innerHTML; This doesnt get the value of the alpha...
4
by: _Who | last post by:
In the .master file I have: <body runat="server" id="MainBody"> I need to add a background attribute to MainBody in the .master.vb file. But there it tells me that MainBody is not declared. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.