body.style?

P

Progman

<body id="body"
style="background-image:url(../../Pictures/System/CountryMosaic.JPG)">

how do i get/set body.style from asp.net?
 
T

Terry Burns

'//You need to set the Runat attribute to server and give it an ID.
<body id="body" runat=server style="MARGIN-LEFT: 20px" vLink="#0000ff">

'//Declare the variable In the designer section
Protected body As System.Web.UI.HtmlControls.HtmlGenericControl

'//In your page load event ( or wherever ) use it
Response.Write(body.Attributes("style").ToString)
 
P

Progman

I tried thi`s:
<body id="body" runat="server"

then you will be able to this
body.style = "background-Image...."

but the compiler says, style is read-only

shit...
 
P

Progman

ok found it
<body id="body1" runat="server" >

Me.body1.Attributes("style") =
"background-image:url(../../Pictures/System/CountryMosaic.JPG)"
 
T

Terry Burns

Style is readonly, but you can set this using the attibutes collection

Control.Attributes.Item("style") = " your style attributes "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top