473,395 Members | 1,972 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,395 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 9153
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dominic Myers | last post by:
Hi there, wondered if someone could point me to an appropriate tutorial or offer advice on the following problem? I've got a web page which uses lots of divs to position the content of the...
0
by: Isz | last post by:
Hi... I can load images into a webform with the following code, but I can't get the width or height properties... but I can set them ok... I figure it might be because the images aren't loaded...
0
by: Christian Pické | last post by:
Hi, I have a Hyperlink with an ImageUrl. Altough I set the Width and Height at 100 px, the image is showed at his original size. I checked the Width and Height settings in the properties as well...
2
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not...
4
by: Doug van Vianen | last post by:
Hi, I have the following coding on a web page. It causes two pictures (pic1.jpg and pic2.jpg) to show, one above the other and then when one clicks on the top picture is squeezes to the left...
4
by: Hiwj | last post by:
I am having a problem with a cell in a table in ASP.NET which used to work OK in classic ASP. I have one cell in a row where the width should be 22 pixels and the other cell should take up the...
1
by: Mike P | last post by:
I am adding a hyperlink to a table and I want the hyperlink to open a window with height and width I can set myself when it is clicked : HyperLink hypGetExtractSQL = new HyperLink(); ...
1
by: ranger979 | last post by:
I am using the emptydatatemplate for a gridview control. I have a detailsview control within the emptydatatemplate. In the detailsview I have another templatefield that contains an imagebutton...
1
by: ranger979 | last post by:
I am using the emptydatatemplate for a gridview control. I have a detailsview control within the emptydatatemplate. In the detailsview I have a templatefield that contains an imagebutton control...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.