jimbona27
asked on
how to apply a css background-image in the code behind file
hi there,
i've come across a problem that I cant figure out looking through the options for a <div id="test" runat="server">..
I need to dynamically set a background-image to a <div>.
i have tried the following
<div <literal></literal>>
my content
</div>
literal1.text = "style:background-image... ";
(this wouldnt be a nice way of doing even if it worked)
i've also tried
<div id="panel1" runat="server">
code behind:
panel1.ApplyStyleSheetSkin = "background-image: url()";
not sure how to use ApplyStyleSheetSkin but that was my best attempt
I could write the entire div out using a literal control I guess, like so,
<literal></literal>
literal1.text = "<div style=background-image:url ...>conten t</div>";
but i assume there's a nicer way of doing it?
enlighten me!
thank,
i've come across a problem that I cant figure out looking through the options for a <div id="test" runat="server">..
I need to dynamically set a background-image to a <div>.
i have tried the following
<div <literal></literal>>
my content
</div>
literal1.text = "style:background-image...
(this wouldnt be a nice way of doing even if it worked)
i've also tried
<div id="panel1" runat="server">
code behind:
panel1.ApplyStyleSheetSkin
not sure how to use ApplyStyleSheetSkin but that was my best attempt
I could write the entire div out using a literal control I guess, like so,
<literal></literal>
literal1.text = "<div style=background-image:url
but i assume there's a nicer way of doing it?
enlighten me!
thank,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok thanks great stuff
<div id="panel1" style="background-image=ur
and then set the variable up in the code:
Public strImageUrl As String
and then set that to anything you require.