473,379 Members | 1,542 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,379 software developers and data experts.

Body.Attributes.Add

Hi,

I have a master file with the following setting
<body runat="server" id="Body">
and in the .cs I have
Body.Attributes.Add("onload",
"menuCurrentPage('current','navlist');");

Now in one of my content files I want to add an additional parameter
to the onload
HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "alert('hello world');");

However, this overwrites the value in my onload attribute on the
master page and so I lose 'menuCurrentPage('current','navlist');"); '.
How can I append from my content page to an attribute in my master
page? so that the end result would be
<body onload='menuCurrentPage('current','navlist');"); alert('hello
world');");'>
Thanks
M.

Aug 24 '07 #1
5 8348
Try this:

Body.Attributes("onload") += "alert('hello world');"
Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
mazdotnet wrote:
Hi,

I have a master file with the following setting
<body runat="server" id="Body">
and in the .cs I have
Body.Attributes.Add("onload",
"menuCurrentPage('current','navlist');");

Now in one of my content files I want to add an additional parameter
to the onload
HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "alert('hello world');");

However, this overwrites the value in my onload attribute on the
master page and so I lose 'menuCurrentPage('current','navlist');"); '.
How can I append from my content page to an attribute in my master
page? so that the end result would be
<body onload='menuCurrentPage('current','navlist');"); alert('hello
world');");'>
Thanks
M.
Aug 24 '07 #2
On Aug 24, 2:58 pm, Steve <lnuxguy_NOMAIL_PLEA...@gmail.comwrote:
Try this:

Body.Attributes("onload") += "alert('hello world');"

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA

mazdotnet wrote:
Hi,
I have a master file with the following setting
<body runat="server" id="Body">
and in the .cs I have
Body.Attributes.Add("onload",
"menuCurrentPage('current','navlist');");
Now in one of my content files I want to add an additional parameter
to the onload
HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes.Add("onload", "alert('hello world');");
However, this overwrites the value in my onload attribute on the
master page and so I lose 'menuCurrentPage('current','navlist');"); '.
How can I append from my content page to an attribute in my master
page? so that the end result would be
<body onload='menuCurrentPage('current','navlist');"); alert('hello
world');");'>
Thanks
M.- Hide quoted text -

- Show quoted text -

I tried it and it says
body.Attributes("onload") += "alert('hello world');";
System.Web.UI.HtmlControls.HtmlControl.Attributes' is a 'property' but
is used like a 'method'
Any idea?

Thx

Aug 24 '07 #3
mazdotnet:
I tried it and it says
body.Attributes("onload") += "alert('hello world');";
System.Web.UI.HtmlControls.HtmlControl.Attributes' is a 'property' but
is used like a 'method'
Any idea?
body.Attributes["onload"] += "alert('hello world');";

--
AreKc
Aug 24 '07 #4
On Aug 24, 4:32 pm, AreKc <ar...@asterdotnet.plwrote:
mazdotnet:
I tried it and it says
body.Attributes("onload") += "alert('hello world');";
System.Web.UI.HtmlControls.HtmlControl.Attributes' is a 'property' but
is used like a 'method'
Any idea?

body.Attributes["onload"] += "alert('hello world');";

--
AreKc
Still no go. In my content page I have

HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes["onload"] += "alert('hello world');";

However, on the generated page it still doesn't come up

<body id="ctl00_Body" onload="menuCurrentPage('current','navlist');">

No alert('hello world')

Anything else I could be missing

Thx
M

Aug 24 '07 #5
"mazdotnet" <ma*******@gmail.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
HtmlControl body = (HtmlControl)Master.FindControl("Body");
body.Attributes["onload"] += "alert('hello world');";
((HtmlGenericControl)Master.FindControl("Body")).A ttributes["onload"] +=
"alert('hello world');";
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 24 '07 #6

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

Similar topics

9
by: Frances Del Rio | last post by:
when I test my stuff with the validator in HomeSite it tells me the body tag no longer reads margin attributes.. does this mean now margins are to be specified only in CSS? I work for an...
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>...
2
by: James Cooke | last post by:
I want to set body attributes programmatically, from the module file: I can go into the .aspx file and say <body onload="myFunc()"> but I don't want to. Like you do with a textbox control: ...
8
by: localhost | last post by:
I would like to wrap all of the HTML inside of my <body> tag inside a <div> with in my code-behind. I do not want to touch the .aspx page template at all. I know how to make the body tag...
2
by: Joy | last post by:
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") =...
3
by: Alan No Spam | last post by:
I am using Visual Studio 2003 and in order not to repeat body tag details in every page <body leftmargin=0 topmargin=0 .... I put those details as an variable in my class: public class...
1
by: jiatiejun | last post by:
I want to add BODY Attributes example: from <bodyto <body leftmargin="0" topmargin="0" or from <bodyto <body onload="window_onload()" how to set the BODY ?
6
by: _Who | last post by:
I use the code below to change to a style sheet that has: body { ....
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.