I am programming for the first time in ASP.NET. It's proven to be very easy and I'm really enjoying it. One feature I like is that, within a web page, I can reference files from root by using the tilde (~) character and then the rest of the path. However, this does not seem to be consistent. For example, it works within the context of href, e.g.
<link href="~/css/StyleSheet.css" />
It doesn't work with respect to src, e.g.
<img src="~/images/header.jpg" />
Why is this? Is there something I'm doing wrong. The inconsistency is annoying.
From my experience the ~
trick only works in server controls. If your img has runat="server"
that should fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With