Solved

Virtual Path with Tilde won't work on Background images

Posted on 2008-10-08
6
325 Views
Last Modified: 2013-11-07
I am trying to simplify my image within my project by putting them all in the root folder but my background images no long work. For example,

<TD runat="server" background="~/images/someimage.gif">

this won't show although the I was informed that all items where runat="server" can be used should be able to identify the tilde.
Can anyone tell me what I am doing wrong? Thanks.
0
Comment
Question by:wilcor14
  • 4
6 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22670542
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22670620
oops i just say what was not working.

<TD> is not a server object, no matter that you put   runat="server"
the server object is
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
bot it wond work either since it don t ave a  background-image property and use the style fot that
it should be <td style="background-image:url(<%= ResolveClientUrl("~/Images") %>/someimage.gif">
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22670775
in just checke my code and i saw i made this using a css file:
in the CSS file
.yourCSSClassName{
background: url(images/someimage.gif);
}
in the aspx page
<TD class="yourCSSClassName">
it worked for my and i moved to a production environement
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 7

Expert Comment

by:ASPSQLServerCOM
ID: 22673765
use

Path = Server.MapPath(ImagefolderName);

or other the best way to code is using \ and ..\
http://www.asp101.com/resources/paths.asp

0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 500 total points
ID: 22677898
Ok, i see the problem. it<s look like the Style property dont like the <%= , so i guess you can`t use the ~ int that particular case.
So, you have 2 choices,
  1. You do has ASPSQLServerCOM sujess and use the . and .. to set the path of the background image relative to the aspx fils`s path.
  2. You use the CSS file to define it, then the path of images is relative to the CSS file`s path.
I saw another question about that, it<s about master pages, but i think the problem is the same...:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_23017096.html 
0
 

Author Closing Comment

by:wilcor14
ID: 31504304
Thanks that was very helpful.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now