473,732 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ima geUrl = "spacer.gif "
myHyperLink.Nav igateUrl = "default.as px"
myHyperLink.Att ributes("style" ) =
"style="bor der-width:1px;borde r-style:Dotted;he ight:40px;width :128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Co ntrols.Add(myHy perLink)

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

Nov 18 '05 #1
2 6768
Hi Robson ,

Try this:
Dim myHyperLink As HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.Nav igateUrl = "default.as px"
myHyperLink.Att ributes("style" ) =
"style=bord er-width:1px;borde r-style:Dotted;he ight:40px;width :128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
Dim img As New WebControls.Ima ge
img.ImageUrl = "spacer.gif "
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Con trols.Add(img)
PlaceHolder1.Co ntrols.Add(myHy perLink)

--
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************ *******@discuss ions.microsoft. com>
wrote in message news:A8******** *************** ***********@mic rosoft.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.Ima geUrl = "spacer.gif "
myHyperLink.Nav igateUrl = "default.as px"
myHyperLink.Att ributes("style" ) =
"style="bor der-width:1px;borde r-style:Dotted;he ight:40px;width :128px;Z-INDEX
: 103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Co ntrols.Add(myHy perLink)

HTML SOURCE GENERATED BY DYNAMIC LINK
--------------------------------------------------------
<a id="a_empresa" href="aempresa. aspx"
style="position :absolute;left: 415px;top:130px ;width:73px;hei ght:20px;"><img src="/corretoresdeseg uros/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.P age
Dim myHyperLink As HyperLink
Dim img As New WebControls.Ima ge

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

End Sub

Sub AddControls(ByV al ObjectName As String, ByVal Style As String, ByVal
NavigateUrl As String)
myHyperLink = New HyperLink
myHyperLink.ID = ObjectName
img.ImageUrl = "/corretoresdeseg uros/images/spacer.gif"
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Con trols.Add(img)
myHyperLink.Nav igateUrl = NavigateUrl
myHyperLink.Att ributes("style" ) = Style
PlaceHolder1.Co ntrols.Add(myHy perLink)
End Sub

End Class

"Juno" wrote:
Hi Robson ,

Try this:
Dim myHyperLink As HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = "link1"
myHyperLink.Nav igateUrl = "default.as px"
myHyperLink.Att ributes("style" ) =
"style=bord er-width:1px;borde r-style:Dotted;he ight:40px;width :128px;Z-INDEX:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
Dim img As New WebControls.Ima ge
img.ImageUrl = "spacer.gif "
img.Width = Unit.Pixel(100)
img.Height = Unit.Pixel(100)
myHyperLink.Con trols.Add(img)
PlaceHolder1.Co ntrols.Add(myHy perLink)

--
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************ *******@discuss ions.microsoft. com>
wrote in message news:A8******** *************** ***********@mic rosoft.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.Ima geUrl = "spacer.gif "
myHyperLink.Nav igateUrl = "default.as px"
myHyperLink.Att ributes("style" ) =

"style="bor der-width:1px;borde r-style:Dotted;he ight:40px;width :128px;Z-INDEX
:
103; LEFT: 408px; POSITION: absolute; TOP: 208px"
PlaceHolder1.Co ntrols.Add(myHy perLink)

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

style="position :absolute;left: 415px;top:130px ;width:73px;hei ght:20px;"><img
src="/corretoresdeseg uros/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
6703
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 application is based on mysql and php on a remote server, and is accessed by the user via a web browser, primarilly IE. The image file names are built up by the server side php scripts, and so a URL for the image file is created, but the file itself is...
0
1408
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 as in HTML. They are there and in design mode the control box is showed at the 100 px size. Any ideas? TIA
1
1909
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 image control, but when i call the height and width properties of the image control it returns "" since they are not set. So how can i get this info? thanks mustafa
1
9251
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...
8
3797
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 System.Web.UI.WebControls.Image Control or a HyperLink and Image Controls, but the onMouseOver and onMouseOut attributes must be in the <img> tag. If I were to use the HyperLink's ImageUrl property and add the attributes using the...
1
2042
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
8
2441
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 pictures vertically so what I'm getting at is... can I know whether an image was taken horizontally or vertically so I can make the proper width/ height lengths so that it looks nice and not kinda weird... because if you make the width bigger...
2
13417
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 != "") { document.getElementById('newImg').src = sel; document.getElementById('newImgDiv').style.visibility = "visible"; } }
22
60817
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. Because the images can all be of different sizes (nothing I can do about that... outside my control), I use a CSS trick to get them all centered both vertically and horizontally, and scaled down to a proper size. Basically, I put the image tag...
0
8946
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
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
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
9235
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
9181
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...
1
6735
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
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
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.