473,769 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using an image in the Hyperlink

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 <atag rather than the <imgtag,
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.

Oct 5 '07 #1
3 2959
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 <atag rather than the <imgtag,
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.

Oct 5 '07 #2
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" <nj********@hot mail.com写入 息
news:u3******** ******@TK2MSFTN GP02.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 <atag rather than the <imgtag,
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.
Oct 5 '07 #3
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 "descriptio n" 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
nj********@hotm ail.com
http://www.nathansokalski.com/

"Peter Bromberg [C# MVP]" <pb*******@yaho o.yohohhoandabo ttleofrum.comwr ote
in message news:3D******** *************** ***********@mic rosoft.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 <atag rather than the <imgtag,
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.


Oct 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
15702
by: Imran | last post by:
Hi, I am attempting to create a CSS-driven website, in that I want to be able to control the display/content from the CSS file. I do not want to use tables. On a page, I have a background image (that contains smaller images) and I would like to assign the smaller images as hyperlinks. What is the best way to do this? I know I can use an imagemap, but is
1
2953
by: Neil Woodvine | last post by:
***Scenario ... I have a DataList with a hyperlink WebControl in the Item Template. I want to display a 64x64 image in the Hyperlink and set the NavigateURL to the full size image. ***Source Data Item for Databinding is a class with 2 props ... URL Description ***MyMainPage.aspx Page_Load Code ...
5
4894
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically create an html table via javascript. While that table is being dynamically created in a javascript function I would like to dynamically insert text and a hyperlink with an image into each cell.
2
6770
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 set image width. This problem makes my link clickable only on its borders. When viewing HTML source I could see that spacer.gif has no width and height, so HTML shows only 1px x 1 px image.
3
3090
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first and then parse the actual response and modify the src attribute of the
1
9257
by: Nathan Sokalski | last post by:
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...
1
2045
by: Daves | last post by:
my gridview should display a column with an image which also is hyperlinked... No problem with: <asp:HyperLinkField DataNavigateUrlFormatString="~/Groups/Default.aspx?group={0}" DataNavigateUrlFields="GroupID" /> but how on earth can I set the image width??? I can also use the Gridview's OnRowDataBound event to manually add the
1
3455
by: sop23456 | last post by:
Microsoft Access 2003 I have hyperlink the image/picture to another file. When I click on the hyperlink, the image appears using MS Paint. What do I do to view Image/picture in Windows Picture and Fax Viewer instead of MS Paint. The Folder Options in Windows XP is already showing as using Windows Picture with Little Box checked (Always). When I click on the Image/Picture File directly, it opens up with the correct Windows Picture...
8
4458
by: webster5u | last post by:
Hi, I'm encounter a problem here. I hope somebody able helping me. i'm put a "log out" hyperlink overlap a image and that particular image is inside a table cell. I also try align the hyperlink on bottom and right at the cell but the problem is occur. If i set position as absolute then the image and hyperlink will leak out from table. If without the position setting then hyperlink is not overlap the image. Any suggestion? This is my...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10038
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.