Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

How to program add BODY Attributes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jiatiejun - 25 Jul 2007 06:01 GMT
I want to add BODY Attributes

example:
from <body> to
   <body leftmargin="0" topmargin="0"
or
from <body> to
   <body onload="window_onload()"

how to set the BODY ?

thanks
Sergey Poberezovskiy - 25 Jul 2007 06:34 GMT
add runat="server" attribute in your aspx.
You can add id="myBody" and then refer to it in the code as myBody,
or if you do not define an id, then you can find it by iterating through the
controls and comparing TagName, for example:
foreach (Control control in this.Controls){
 if (control is HtmlGenericControl &&
((HtmlGenericControl)control).TagName=="body"){
 // set your variable to this control
 }
}
After you have located the body control, adding attributes is extremely
easy. There is a number of approaches. One of them is as follows:
myBody.Attributes.Add(attName, attValue);

> I want to add BODY Attributes
>
[quoted text clipped - 8 lines]
>
> thanks
chenhong - 25 Jul 2007 06:49 GMT
<body runat="server" id="body1">

in c# you can treat the body like other server control.

body1.Attributes.add("name","value");

"jiatiejun" <jiatiejun@126.com> дÈëÏûÏ¢ÐÂÎÅ:eagIXjnzHHA.4916@TK2MSFTNGP03.phx.gbl...
>I want to add BODY Attributes
>
[quoted text clipped - 8 lines]
>
> thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.