On Mon, 30 Aug 2004 11:04:00 +1200, Chris Mahoney <do**@spam.me> wrote:
Hi
Currently I am setting the background image of my page by using the
following code:
<style type="text/css">
BODY { BACKGROUND-IMAGE: url(myimage.jpg) }
</style>
What I would like to do is change the background image dynamically. My
guess
was to use the Attributes.Add function, but while I can do something like
Button1.Attributes.Add, I can't figure out how to apply attributes to the
entire page.
Am I on the right track or should I being doing something else?
Thanks
Chris
You can make the STYLE tag a server control and then alter it from
code-behind (you can do this with just about any tag in the doc).
My example is changing background-color:
<!-- add an id="" and runat="server" to the tag -->
<style id="hgcStyle" runat="server">
.tb { BACKGROUND-COLOR: red }
</style>
code-behind:
'//you have to declare the control variable yourself, just like the other
controls
Protected WithEvents hgcStyle As
System.Web.UI.HtmlControls.HtmlGenericControl
'//now you can access the tag, e.g.
hgcStyle.InnerText = ".tb {background-color: " & TextBox1.Text & "}"
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET