Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP - .NET 2--5 Themes Problem

Status
Not open for further replies.

Smeat

Programmer
Mar 27, 2004
193
GB
Hi All

In a .NET 2005 web application I am using themes to control my UI.

App_Themes
---Ford
---Images
---rvname-logo.gif
---Styles
---Default.css

In the themes stylesheet I have the following style:

Code:
img.logo
{
	src: url(../Images/rvname-logo.gif);
}

and in my aspx page I have the following html:

Code:
<asp:Image runat="server" CssClass="logo" Width="600" Height="48" ID="img1" />

My problem is that the image src is rendered as:
Code:
<img id="img1" class="logo" src="" style="height:48px;width:600px;border-width:0px;" />

which is not setting the image src attribute.

If I change the stylesheet to:
Code:
background-image: url(../Images/rvname-logo.gif);

it renders the same html but correctly sets the background image but this is no use to me as it shows a broken image on top of the background because it has not been set.

Has anyone else come across this? Does anyone know how to fix this?

Any help appreciated.

TIA

Smeat
 
which is not setting the image src attribute.
Which is the correct behaviour. CSS will apply a style to a HTML element but it cannot render or change an attribute of a HTML element.

Therefore, setting the "background-image" of an element will work correctly as this is a style whereas setting the "src" of the element will not work as the CSS "src" tag is designed to set the "location of a font file".


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks Ca8msm

On the assumption this can't be done i've come up with the following workaround:

In my theme directorym create a skin file:

Code:
<asp:Image runat="server" ImageUrl="Images/rvname-logo.gif" SkinID="logo" AlternateText="Logo" />

Then alter the image tag in the html to refer to the SkinID:

Code:
<asp:Image runat="server" SkinID="logo" Width="600" Height="48" ID="img1" />

Although this is not the way I expected though does work and adding a skin for the image is not really any different to adding a style in the stylesheet.

Hope this helps someone else as I spent far too long on this one.

Ta

Smeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top