Solved

Virtual Path with Tilde won't work on Background images

Posted on 2008-10-08
6
324 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

19 Experts available now in Live!

Get 1:1 Help Now