Solved

Virtual Path with Tilde won't work on Background images

Posted on 2008-10-08
6
329 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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