Solved

Virtual Path with Tilde won't work on Background images

Posted on 2008-10-08
6
328 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Suggested Solutions

Title # Comments Views Activity
Store results in vb.net 3 21
How come this regular expression allows "e"? 14 38
vb.net class 3 16
VB.net Progress Bar - Maximum Value too large 2 12
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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