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