471,354 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Changing the width/height when using Hyperlink.ImageUrl

I am using the ImageUrl property of the Hyperlink control to create a
graphical Hyperlink. However, I want to change the size of the image I am
using, but the generated HTML places the width/height properties in the
anchor tag rather than the image tag. Obviously I could write code to
generate the anchor/image tags myself, but when a control as nice as the
Hyperlink already exists I want to know if there is any kind of workaround
that will let me use the Hyperlink control. Any ideas?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
1 8876
Hi Nathan,

Ive found this same problem, in an online catalog where there was a
thumbnail of product images which should be hyperlinks to the individual
product pages.
There were three ways i've gotten around this, the first is to the text
property of your hypelink control as an image (kinda kludgey):
lnkImage.Text = "<img src='" & ResolveUrl("~/images/someimage.gif") & "'
width=150>"
The next is to directly handle the image control in the hyperlink, which i
only did once or twice, but got it working, something kind of like (not 100%
sure about the sytanx here):
lnkImage.ImageUrl = ResolveUrl("~/images/someimage.gif")
Dim img As Image = lnkImage.Controls(0)
img.Width = New Unit(150, Pixels)
The way i usually do this though is to edit the HTML code and do something
like the following:

<asp:hyperlink id=lnkImage runat=server
navigateurl="~/index.aspx?m=f&id=123">
<asp:image id=imgImage runat=server imageurl="~/images/someimage.gif"
width="150px"></asp:image>
</asp:hyperlink>

Hope this helps, its all workarounds, but they work. You could always
subclass the hyperlink control and override its render event, but these are
easier.

Cheers,
- Arthur Dent.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:e$*************@tk2msftngp13.phx.gbl...I am using the ImageUrl property of the Hyperlink control to create a
graphical Hyperlink. However, I want to change the size of the image I am
using, but the generated HTML places the width/height properties in the
anchor tag rather than the image tag. Obviously I could write code to
generate the anchor/image tags myself, but when a control as nice as the
Hyperlink already exists I want to know if there is any kind of workaround
that will let me use the Hyperlink control. Any ideas?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dominic Myers | last post: by
reply views Thread by Isz | last post: by
reply views Thread by Christian Pické | last post: by
2 posts views Thread by Robson Carvalho Machado | last post: by
4 posts views Thread by Doug van Vianen | last post: by
4 posts views Thread by Hiwj | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.