Its not a bug. This time it really is by design although the design imposes
a conflict with the CSS id selector. As used by the framework, the id
functions as an attribute the compiler needs to build the control tree when
the page is compiled.
The solution is to stop depending on the id selector to apply sytle. Use the
class selector. The id selector has no real value other than its intended
use to identify a once and only once instance in the page. No big deal as
inheritence, cascade and specificity are not affect one iota when not using
id selectors for style.
All the other inclie code block hacks are fine and well to know and have at
hand but simply using class selectors resolves this misperceived bug. Note
there is also something to be learned about class selectors when using
Themes which over-ride inline declarations...
// example when not using Themes which will over-ride the inline class
selector
<img src="~/assets/test.gif" id="gnr" class="ClassName" runat="server"/>
// example when using Themes
<img src="~/assets/test.gif" id="gnr" SkinID="ClassName" />
// .skin file entry
<asp:Image SkinID="ClassName" CssClass="ClassName" runat="server" />
There's more to discuss and learn of course but these points should at least
point you in the right direction with no hacks required noting again, they
are good to know and learn but sometimes not needed.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL
http://metromilwaukee.com/
URL
http://clintongallagher.metromilwaukee.com/
"Mark Olbert" <Ch*********@newsgroups.nospam> wrote in message
news:um********************************@4ax.com...
I have some img tags on a master page which reference files in a top-level
directory. They look like this:
<img src="assets/test.gif" id="gnr" />
assets is a subdirectory of the website root.
My problem is this: this kind of path reference in a master page won't
work when the page using the master is not in the root
folder:
root_page.aspx <- if this uses the master, the image file will be located
and displayed correctly
subdirectory/subdir_page.aspx <- if this uses the master, it won't locate
and display the image file
One solution I've used before is to change the image tag as follows:
<img runat="server" src="~/assets/test.gif" id="gnr" />
This lets the file be found...but unfortunately it makes the img tag not
respond to CSS positioning attributes. Specifically, even
though the gnr id is defined as being absolutely positioned at the right
margin (within relatively positioned div element), it still
floats on the left.
I'm pretty sure this is a bug.
But I'd love to hear how to work around it. Anyone got any ideas? Other
than switching to <asp:image> tags; I got that to work
already.
- Mark