Jaz wrote:I am not totally sure I understand why taking out "~" solves it, but hey it worked.
Imaging "pathing" can be done two ways, depending on the HTML tag being used.
Using the "~/" in an ASP.Net is valid and necessary. It tells the server-side code to substitute the current sites root URL for the "~/". That way, you can write code that isn't dependent on specific store URLs or specific domain names.
In tranditional HTML, the "~" tilde is not used. It's ignored. Pathing is handled via two different methods in the HTML tags.
In HTML, image paths can be "absolute" or "relative" to the current path. In other words, you can reference the image by specifying the complete (absolute) path to the URL or by specifying a shorter (and sometimes more confusing) path, relative, to the current path.
Add into the mix the difference between server-side and client-side controls and things get confusing.
An easy shortcut to remember is simple: If the HTML tag DOESN'T start with <asp:...>, don't use the "~" tilde.
Secondly, keep in mind how HTML pathing works:
1. Absolute path would be
http://www.trickconcepts.com/images/category.gif. This path only works for your website and only in HTTP.
2. Relative path could be done in two ways. Starting the path with a "/" slash assumes from the root folder of the site. That's generally the best way to specific all your image paths.
So you could use "/images/category.gif" and never have to worry about either the HTTP/HTTPS context or a hard-coded domain name. Ideal.
You could also use full relative pathing which makes URLs dependent on the path of the page you're currently browsing. Say you are browsing /Members/MyAccount.aspx. The current path is "/Members/" . If you added an image "/images/category.gif", it will work because you started it with a "/" slash - that told the browser to look for the images folder starting from the root of the site.
But let's say the /Members/MyAccount.aspx page didn't use the slash on the image path. You just add an image with a path of "images/category.gif" but it refuses to work. The reason is without the slash, the browser will assume "based on the current path". So in that example, you would need to have a sub-folder underneath Members called images. The actual full path would then become /Members/images/category.gif.
Notice in that 2nd example, nowhere did I use the "~" tilde. Standard HTML is just going to ignore it, but it still seems to work because you used "~/". Without the tilde, the "/" slash was still there so the path is going to be relative from the root of the site.
The whole thing gets worse - you've probably seen paths 'like "../" or "../../../" or some such nonsense. The "../" means "Go back up 1 level in the directory tree and start looking from there". So in our /Members/MyAccount.aspx page, we could have actually used an image path of "../images/category.gif" and it would have still worked. But, you'd be hosed if you ever moved the MyAccount page to a different folder since the image path was relative based on the assumption of being in the /Members/ folder.
Clear as mud? Welcome to HTML
