Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Changing the width/height when using Hyperlink.ImageUrl

Reply
Thread Tools

Changing the width/height when using Hyperlink.ImageUrl

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      10-08-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Arthur Dent
Guest
Posts: n/a
 
      10-10-2005
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" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
>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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
 
 
 
etterum etterum is offline
Junior Member
Join Date: Dec 2008
Posts: 1
 
      12-08-2008
Arthur Dent, thanks dude, you really saved my day !

Cheers and happy hitchhiking!
 
Reply With Quote
 
alexhiggins732 alexhiggins732 is offline
Junior Member
Join Date: Feb 2010
Posts: 1
 
      02-09-2010
My favorite solution is to use css

<style>.thumb80 img {width:80px}</style>
...
<asp:hyperlink CssClass="thumb80" id=lnkImage runat=server
navigateurl="~/index.aspx?m=f&id=123" imageurl="~/images/someimage.gif"
/>
 
Reply With Quote
 
nazanim2000 nazanim2000 is offline
Junior Member
Join Date: May 2010
Location: Iran
Posts: 1
 
      06-02-2010
Arthur Dent Thank you sooo much!!!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing style of the numbers in a CSS <ol> without changing the style of the <li> Aaron Beall HTML 2 09-14-2007 08:07 PM
<FAQENTRY>I'm changing my page but nothing is changing on the screen. Why?</FAQENTRY> VK Javascript 3 03-15-2007 04:59 PM
changing file extension without changing filename jamy Computer Support 4 03-04-2005 01:03 AM
Changing code form using response.outputstream 1 ASP .Net 2 01-27-2004 01:50 AM
Difficulty in changing the Connection Server control path changing ... Samridhi Kumar Shukla ASP .Net 1 11-30-2003 02:31 AM



Advertisments