473,378 Members | 1,671 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,378 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 9141
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.