Welcome Guest Search | Active Topics | Members | Log In | Register

Using an image in the Hyperlink Options · View
Nathan Sokalski
Posted: Friday, October 05, 2007 5:05:36 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 05:05:36
Date: Fri, 5 Oct 2007 09:05:36 -0400

I am using the ImageUrl property of the HyperLink control. My image is
large, so I am setting the width/height attributes, but when it renders the
width/height attributes are in the <a> tag rather than the <img> tag,
therefore not making the image the size I want. I can obviously place an
Image control inside the HyperLink, but the HyperLink was obviously intended
to render both. Is there a way around this without using multiple controls?
Thanks.

Nathan Sokalski
Posted: Friday, October 05, 2007 4:14:12 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 05/10/2007 16:14:12
Date: Fri, 5 Oct 2007 20:14:12 -0400

It is not that big of a deal to use two controls, but it is a pain in the
neck. But my main purpose of this posting was to point out that when using
the ImageUrl property of the HyperLink, it's Width and Height properties do
not do what you would expect. I would expect them to be applied to the
Image, because my "description" of using the HyperLink's ImageUrl property
is basically an ImageButton that links to another page rather than doing a
postback. I think that the reason for the Width property working in the
ImageButton but not the HyperLink is the fact that because they derive from
the WebControl class, the Width property is predefined, and is always
applied to the TagKey property (the outermost tag), which in an ImageButton
is <input>, the only tag involved but in HyperLink it is <a>, which is not
what we actually want the Width of. I think that this was bad design by
Microsoft, if I were to redesign the HyperLink I would Override the Width
and Height properties and detect whether the Hyperlink was using text or an
image. But that is just my opinion, and it has a simple workaround, so I
won't make too big a deal out of it.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Peter Bromberg [C# MVP]" <pbromberg@yahoo.yohohhoandabottleofrum.com> wrote
in message news:3D6F343D-7885-449C-B592-CA02C98EB808@microsoft.com...
> Since the Hyperlink control does not offer any properties for the image if
> an
> ImageUrl is specified, the only way to "get around" this limitation would
> be
> to try to specify some CSS properties.
>
> Otherwise, you'll need to use two controls. Why is that such a big deal?
> Peter
> --
> Recursion: see Recursion
> site: http://www.eggheadcafe.com
> unBlog: http://petesbloggerama.blogspot.com
> BlogMetaFinder: http://www.blogmetafinder.com
>
>
>
> "Nathan Sokalski" wrote:
>
>> I am using the ImageUrl property of the HyperLink control. My image is
>> large, so I am setting the width/height attributes, but when it renders
>> the
>> width/height attributes are in the <a> tag rather than the <img> tag,
>> therefore not making the image the size I want. I can obviously place an
>> Image control inside the HyperLink, but the HyperLink was obviously
>> intended
>> to render both. Is there a way around this without using multiple
>> controls?
>> Thanks.
>>
>>


<xueduanyang@msn.com>
Posted: Saturday, October 06, 2007 5:41:09 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 05:41:09
Date: Fri, 5 Oct 2007 21:41:09 +0800

I can`t understand how to view a image using HyperLink control, that is to
make a href ,not a image .If you still want to do like this, you can try the
replace method to change the tag "a" into "img".

"Nathan Sokalski" <njsokalski@hotmail.com> 写入消息
news:u3M7TC1BIHA.2268@TK2MSFTNGP02.phx.gbl...
>I am using the ImageUrl property of the HyperLink control. My image is
>large, so I am setting the width/height attributes, but when it renders the
>width/height attributes are in the <a> tag rather than the <img> tag,
>therefore not making the image the size I want. I can obviously place an
>Image control inside the HyperLink, but the HyperLink was obviously
>intended to render both. Is there a way around this without using multiple
>controls? Thanks.

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.060 seconds.