473,387 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with img tag and VS 2005

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/Ima...32x32-plus.png

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

WTF???

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

Thanks
Lloyd Sheen

Oct 30 '07 #1
3 3026
"Lloyd Sheen" <a@b.cwrote in message
news:eq****************@TK2MSFTNGP03.phx.gbl...
The asp:ImageButton generates the follow URL:
http://localhost:57217/MusicSite/Ima...32x32-plus.png

The img generates the following URL:
http://localhost:57217/MusicSite/~/I...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. <img.../don't, unless you include runat="server"...
is there a way of have the imagebutton not make postbacks??
Why don't you just use an <asp:Image /control...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 31 '07 #2
The "img" Html control is not an ASP.NET Server-side control, it's a plain
old HTML control. Therefore, the "~" - which would only be processed at the
server, is meaningless, hence your problem. You could either put a
runat="server' attribute on it, or simply use the ASP.NET <asp:Image ...>
control.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Lloyd Sheen" wrote:
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/Ima...32x32-plus.png

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

WTF???

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

Thanks
Lloyd Sheen

Oct 31 '07 #3

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:Ox**************@TK2MSFTNGP03.phx.gbl...
"Lloyd Sheen" <a@b.cwrote in message
news:eq****************@TK2MSFTNGP03.phx.gbl...
>The asp:ImageButton generates the follow URL:
http://localhost:57217/MusicSite/Ima...32x32-plus.png

The img generates the following URL:
http://localhost:57217/MusicSite/~/I...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. <img.../don't, unless you include runat="server"...
>is there a way of have the imagebutton not make postbacks??

Why don't you just use an <asp:Image /control...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Thanks went the asp:Image route. Works great. Not sure why I was using the
ImageButton

Lloyd Sheen

Oct 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: MattP | last post by:
Ok, with the help of some examples found on the web and some minor modifications on our own, we have a simple and working encrypt and decrypt solution. It runs as a service, watches for files with...
5
by: drdeadpan | last post by:
I asked the DBA to start the Server with options -T1204 and -T3605 and here's what I get. I need help deciphering this. This happens when we have 5 usrs performing concurrent actions and for the...
1
by: steven.fafel | last post by:
I have been working with SQL for a while...but I am stumped. I can not seem to get my arms around this query....can anyone help... Here it is: Table = 12 rows, 4 columns (id, name, amount,...
2
by: KoliPoki | last post by:
Greetings. I'm having a little trouble with a query. The idea is simple I need to display a list of recently unique visited URLs and the last time I visited. I have 2 table one stores the...
7
by: angelasg | last post by:
Here is sample data I'm working with: ID ShiftDate SegTime 99 5/2/2005 5/2/2005 1:00:00 PM 99 5/2/2005 5/2/2005 1:04:00 PM 99 5/2/2005 5/2/2005 1:43:00 PM 99 5/2/2005...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
1
by: prabhukalyan | last post by:
Hi all, I am not so good in queries. here is my problem 2 tables to store the received items (fabric)-- inwardmaster, inwarddetails and after some processing (Dyeing) the items were...
5
by: Matik | last post by:
Hello, I've very often a deadlock problem. The deadlock is generated always in the same way, by one application calling in DB two sp's (application has two threads). This is an error message...
4
by: | last post by:
Environment: Microsoft Visual Studio 2005 Professional Edition Microsoft Visual Source Safe 2005 FxCop 1.32 Project: ASP.NET 2.0 C# Project 5 Developers We are trying to implement FxCop...
4
by: Fred Flintstone | last post by:
This one baffles me. I'm using VS.Net 2005 and write desktop apps that need built in help. So logically, I figure maybe VS has a help system component built in so I search the help. Hey! ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.