Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Virtual Path with Tilde won't work on Background images

Posted on 2008-10-08
6
Medium Priority
?
344 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

963 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