Help with img tag and VS 2005

L

Lloyd Sheen

I am trying to move away from server image tags (don't need a postback) and
am having a real difficult time getting the image to show properly.

The following code is in a repeater:

<table>
<tr>
<td>
<asp:ImageButton Height="16px"
ID="ImageLeft" ImageUrl="~/Images/music-32x32.png"
AlternateText='<%# Eval("FileName")%>'
runat="server" />
</td>
</tr>
<tr>
<td>
<img alt="" id="ImageLeftPlus"
src="~/Images/music-32x32-plus.png" height="16px" />
<asp:ImageButton Height="16px"
ID="ImageLeftPlus1" ImageUrl="~/Images/music-32x32-plus.png"
AlternateText='<%# Eval("FileName")%>'
runat="server" />
</td>
</tr>
</table>

Note that image src or ImageUrl are the same for the two buttons in the
bottom tr.

Using the IE Developer Toolbar I can see the following:

The asp:ImageButton generates the follow URL:
http://localhost:57217/MusicSite/Images/music-32x32-plus.png

The img generates the following URL:
http://localhost:57217/MusicSite/~/Images/music-32x32-plus.png

WTF???

I can't make heads nor tails of what is going on. What would the correct
src for the <img> tag be or is there a way of have the imagebutton not make
postbacks??

Thanks
Lloyd Sheen
 
M

Mark Rae [MVP]

The asp:ImageButton generates the follow URL:
http://localhost:57217/MusicSite/Images/music-32x32-plus.png

The img generates the following URL:
http://localhost:57217/MusicSite/~/Images/music-32x32-plus.png

I can't make heads nor tails of what is going on.

Only web controls e.g. asp:ImageButton understand the tilde shortcut - HTML
controls e.g. said:
is there a way of have the imagebutton not make postbacks??

Why don't you just use an <asp:Image /> control...?
 
L

Lloyd Sheen

Mark Rae said:
Only web controls e.g. asp:ImageButton understand the tilde shortcut -


Why don't you just use an <asp:Image /> control...?

Thanks went the asp:Image route. Works great. Not sure why I was using the
ImageButton

Lloyd Sheen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top