473,395 Members | 1,403 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.

How to set width and height of image using HyperLink Control?

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.

What can I do to make all the area clickable?

CODEBEHIND
-----------------
Dim myHyperLink as HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.ImageUrl = "spacer.gif"
myHyperLink.NavigateUrl = "default.aspx"
myHyperLink.Attributes("style") =
"style="border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Controls.Add(myHyperLink)

HTML SOURCE GENERATED BY DYNAMIC LINK
--------------------------------------------------------
<a id="a_empresa" href="aempresa.aspx"
style="position:absolute;left:415px;top:130px;widt h:73px;height:20px;"><img
src="/corretoresdeseguros/images/spacer.gif" border="0" /></a>

Nov 18 '05 #1
2 6731
Hi Robson ,

Try this:
Dim myHyperLink As HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.NavigateUrl = "default.aspx"
myHyperLink.Attributes("style") =
"style=border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
Dim img As New WebControls.Image
img.ImageUrl = "spacer.gif"
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Controls.Add(img)
PlaceHolder1.Controls.Add(myHyperLink)

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET

"Robson Carvalho Machado" <Ro*******************@discussions.microsoft.com >
wrote in message news:A8**********************************@microsof t.com...
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.

What can I do to make all the area clickable?

CODEBEHIND
-----------------
Dim myHyperLink as HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.ImageUrl = "spacer.gif"
myHyperLink.NavigateUrl = "default.aspx"
myHyperLink.Attributes("style") =
"style="border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX
: 103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Controls.Add(myHyperLink)

HTML SOURCE GENERATED BY DYNAMIC LINK
--------------------------------------------------------
<a id="a_empresa" href="aempresa.aspx"
style="position:absolute;left:415px;top:130px;widt h:73px;height:20px;"><img src="/corretoresdeseguros/images/spacer.gif" border="0" /></a>

Nov 18 '05 #2
Dear Juno,

Thanks for your help!

The solution has worked in part.

As you can see, my links are placed by a Function named AddControls.

By using your solution only the last HyperLink placed receives img.width and
img.height.

Can you help me with the correction of the below code?
Public Class dynamic
Inherits System.Web.UI.Page
Dim myHyperLink As HyperLink
Dim img As New WebControls.Image

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AddControls(“link1”,
“border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX: 103;
LEFT: 408px; POSITION: absolute; TOP: 208px”, “default.aspx”)
AddControls(“link2”,
“border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX: 103;
LEFT: 488px; POSITION: absolute; TOP: 208px”, “services.aspx”)

End Sub

Sub AddControls(ByVal ObjectName As String, ByVal Style As String, ByVal
NavigateUrl As String)
myHyperLink = New HyperLink
myHyperLink.ID = ObjectName
img.ImageUrl = "/corretoresdeseguros/images/spacer.gif"
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Controls.Add(img)
myHyperLink.NavigateUrl = NavigateUrl
myHyperLink.Attributes("style") = Style
PlaceHolder1.Controls.Add(myHyperLink)
End Sub

End Class

"Juno" wrote:
Hi Robson ,

Try this:
Dim myHyperLink As HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.NavigateUrl = "default.aspx"
myHyperLink.Attributes("style") =
"style=border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
Dim img As New WebControls.Image
img.ImageUrl = "spacer.gif"
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Controls.Add(img)
PlaceHolder1.Controls.Add(myHyperLink)

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET

"Robson Carvalho Machado" <Ro*******************@discussions.microsoft.com >
wrote in message news:A8**********************************@microsof t.com...
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.

What can I do to make all the area clickable?

CODEBEHIND
-----------------
Dim myHyperLink as HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.ImageUrl = "spacer.gif"
myHyperLink.NavigateUrl = "default.aspx"
myHyperLink.Attributes("style") =

"style="border-width:1px;border-style:Dotted;height:40px;width:128px;Z-INDEX
:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Controls.Add(myHyperLink)

HTML SOURCE GENERATED BY DYNAMIC LINK
--------------------------------------------------------
<a id="a_empresa" href="aempresa.aspx"

style="position:absolute;left:415px;top:130px;widt h:73px;height:20px;"><img
src="/corretoresdeseguros/images/spacer.gif" border="0" /></a>


Nov 18 '05 #3

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

Similar topics

3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
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...
1
by: Mustafa Rabie | last post by:
dear all, i am writing an application where the user can upload his own picture. I wanted to get the Width and Height of the uploaded picture. So i assigned the uploaded image to an aspnet...
1
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...
8
by: Nathan Sokalski | last post by:
I have several System.Web.UI.WebControls.HyperLink Controls which I want to display as rollover images. I know how to make these manually using the <a> and <img> tags or the <a> tag and a...
1
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}"...
8
by: Kentor | last post by:
Hello, I have users that submit images to my website. By default I choose to make the width bigger than the height because usually pictures are taken horizontally... But in some cases people take...
2
by: Atul | last post by:
I am unable to find image height and width in mozilla firefox. My code is working in IE but not in Mozilla. How can i find image width and height in mozilla? function check(sel) { if(sel != "")...
22
Atli
by: Atli | last post by:
Hi. I'm setting up a small photo-album-type thing, where I use PHP to set up a list of images for visitors to click through. That's all simple enough. However, I'm having a weird bug in IE8. ...
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: 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?
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.