473,399 Members | 3,919 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,399 software developers and data experts.

change the value of a custom attribute on a <BODY> tag

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>
</body>
</html>

I want to affect the value of the 'test' attribute from the code-behind
file.

I've tried setting up the body tag as a server control (e.g. <body id="fred"
runat="server" test="colin">) and adding in a protected var in the
codebehind like this:
protected System.Web.UI.HtmlControls.HtmlGenericControl mainbody;

... but it throws an exception somewhere deep down in the .net libraries
before it runs any of my code. Anyone got any ideas about how I could do
this?
Nov 16 '05 #1
1 1954
The name of the HtmlGenericControl must be the same as the id in the
asp-page.

<body id="fred" runat="server" test="groovy"/>
protected System.Web.UI.HtmlControls.HtmlGenericControl fred;

Then you can manipulate and read the attributes serverside:
fred.Attributes["test"]=string.Format("{0} code",fred.Attributes["test"]);

/Hugo

On Thu, 9 Sep 2004 12:46:58 +0100, Chris Millar wrote:
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>
</body>
</html>

I want to affect the value of the 'test' attribute from the code-behind
file.

I've tried setting up the body tag as a server control (e.g. <body id="fred"
runat="server" test="colin">) and adding in a protected var in the
codebehind like this:
protected System.Web.UI.HtmlControls.HtmlGenericControl mainbody;

.. but it throws an exception somewhere deep down in the .net libraries
before it runs any of my code. Anyone got any ideas about how I could do
this?

Nov 16 '05 #2

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

Similar topics

0
by: Andrés Giraldo | last post by:
Hi! It's possible to register some script between the <head> and </head> actually I'm Using RegisterStartupScript and RegisterClientBlockScript, but it works on the body By the way... how...
2
by: ryan.mclean | last post by:
Hello everyone. Hope ya'll had a nice New Year. Anyway, my question is why won't this work? I must be doing something dumb . . . here is the code: in the body tag, I have this code (just to...
3
by: francescomoi | last post by:
Hi. I'm trying to insert some text between <head> and <body> but I'm not able. I try with: -------- bodyPoint = document.getElementsByTagName('body'); var myLink =...
15
by: Frances | last post by:
<html> <head> <script> function doIt() { var list = document.forms.product; var selItem = list.options.value; ^^^^^^^ </head>
5
by: SteveS | last post by:
Hello, I'm having trouble figuring out how to dynamically add an onload and resize event to the <body> tag. I've looked on the web and in MS documentation unsuccessfuly. Does anyone know the code...
0
by: WB | last post by:
Hi, How can I add an "onbeforeunload" event to the body tag of the MasterPage? All pages in my site follow a MasterPage and some of these pages require long processing. I'd like to show a...
0
by: Gustavo Arriola | last post by:
In ASP.NET 2.0: How I add an attribute to the tag <body>? From already thank you very much! Gustavo Arriola
1
by: Gustavo Arriola | last post by:
Hello! In ASP.NET 2.0: How I add an attribute to the tag <bodyin Codebehind? From already thank you very much! Gustavo Arriola
23
by: Xah | last post by:
Here's a interesting case of invalid html 4 strict file. In summary, if you have <body></bodywithout any content, the file would be invalid under html 4 strict. Valid if html 4 lose. <!DOCTYPE...
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
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.