473,772 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hyperlink Rollover images in Repeater error

I want to have a rollover image on an hyperlink inside a Repeater control
but when i run the page i get
"Image1 is undefined"
Any ideas?

I have a Hyperlink and an Image control in a repeater like below:-
<ItemTemplate >
<tr width="150px" style="cursor:h and"
onmouseover="st yle.backgroundC olor='#c0c0c0'; "
onmouseout="sty le.backgroundCo lor=''" bordercolor="#0 00000">
<td>
<asp:Image id="Image1" runat="server"
ImageUrl="image s/off.gif"></asp:Image>
<asp:HyperLin k CssClass="a" id="HyperLink1 " Text='<%#
DataBinder.Eval (Container.Data Item, "cat_cities ") %>' NavigateUrl='<% #
"template2.aspx ?CategoryID=" & DataBinder.Eval (Container.Data Item, "catid")
%>' runat="server" />
</td>
</tr>
</ItemTemplate>
And in the repeater i did:-
Sub Repeater_ItemCr eated(ByVal sender As Object, ByVal e As
RepeaterItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
Dim hyperLink As HyperLink =
CType(e.Item.Fi ndControl("Hype rLink1"), HyperLink)
Dim Image As System.Web.UI.W ebControls.Imag e =
CType(e.Item.Fi ndControl("Imag e1"), System.Web.UI.W ebControls.Imag e)

hyperLink.Attri butes.Add("onMo useOver", Image.ClientID &
".src='imag es/up.gif';return true;")
hyperLink.Attri butes.Add("onMo useOut", Image.ClientID &
".src='imag es/off.gif'; return true;")
End If
End Sub

Jan 29 '06 #1
5 2509
When using WebControls to create elements such as images, the generated code
does not include a name attribute unless you include a name property. You
need to add a name="Image1" attribute to your asp:Image tag as follows:

<asp:Image id="Image1" name="Image1" runat="server"
ImageUrl="image s/off.gif"></asp:Image>

Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I want to have a rollover image on an hyperlink inside a Repeater control
but when i run the page i get
"Image1 is undefined"
Any ideas?

I have a Hyperlink and an Image control in a repeater like below:-
<ItemTemplate >
<tr width="150px" style="cursor:h and"
onmouseover="st yle.backgroundC olor='#c0c0c0'; "
onmouseout="sty le.backgroundCo lor=''" bordercolor="#0 00000">
<td>
<asp:Image id="Image1" runat="server"
ImageUrl="image s/off.gif"></asp:Image>
<asp:HyperLin k CssClass="a" id="HyperLink1 " Text='<%#
DataBinder.Eval (Container.Data Item, "cat_cities ") %>' NavigateUrl='<% #
"template2.aspx ?CategoryID=" & DataBinder.Eval (Container.Data Item,
"catid")
%>' runat="server" />
</td>
</tr>
</ItemTemplate>
And in the repeater i did:-
Sub Repeater_ItemCr eated(ByVal sender As Object, ByVal e As
RepeaterItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
Dim hyperLink As HyperLink =
CType(e.Item.Fi ndControl("Hype rLink1"), HyperLink)
Dim Image As System.Web.UI.W ebControls.Imag e =
CType(e.Item.Fi ndControl("Imag e1"), System.Web.UI.W ebControls.Imag e)

hyperLink.Attri butes.Add("onMo useOver", Image.ClientID &
".src='imag es/up.gif';return true;")
hyperLink.Attri butes.Add("onMo useOut", Image.ClientID &
".src='imag es/off.gif'; return true;")
End If
End Sub

Jan 29 '06 #2
Thanks Nathan i tried that but no LUCK.
Any more ideas?

*** Sent via Developersdex http://www.developersdex.com ***
Jan 30 '06 #3
One thing that I might try looking at is view generated HTML by doing a
View -> Source from your browser to make sure the tags in the generated code
have the same name that you think they do. Sometimes in the Repeater,
DataList, and DataGrid Controls the name attribute is modified to allow
Javascript to distinguish between the controls.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Rote Rote" <na********@hot mail.com> wrote in message
news:eL******** *****@TK2MSFTNG P09.phx.gbl...
Thanks Nathan i tried that but no LUCK.
Any more ideas?

*** Sent via Developersdex http://www.developersdex.com ***

Jan 30 '06 #4
Yeah i did that and i know that.
Thanks Nathan would do one more thing i think could make it work and
would let you know.
Thanks for the advice
*** Sent via Developersdex http://www.developersdex.com ***
Jan 31 '06 #5
Nathan i got it fixed i used
hyperLink.Attri butes.Add("onMo useOver", "document.getEl ementById('" &
Image.ClientID & "').src='im ages/up.gif';return true;")
hyperLink.Attri butes.Add("onMo useOut",
"document.getEl ementById('" & Image.ClientID & "').src='im ages/off.gif';
return true;")
in the ItemDataBound of my Repeater and it worked like a charm although
it might be a good idea adding the name attirbute to the image control
but still worked just by using the ID.
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Feb 2 '06 #6

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

Similar topics

9
1497
by: Steven Daedelus | last post by:
Hey folks, Can someone take a look at this page and tell me what's up: http://caraher.org/ You'll notice that the "links" button, which has a rollover script attached, doesn't work. I've stared at it for far too long and can't spot the problem. It's out-of-the-box Dreamweaver code, as I was not getting paid enough to do any custom work here, but I've never had any
3
2723
by: JOSEPHINE ALVAREZ | last post by:
I have this code that I want to use to do a rollover. However, because the company I am doing it for is continually changing the text, I want to be able to use dynamic text to change the text on the fly, and still have the rollover work. I have taken the text off of the buttons, but cannot figure out how to do it with dynamic text using javascript and html. For example, in the columns of this row, I want to put "About...
2
2626
by: Peter Eriksson | last post by:
I am making a link with the HyperLink-class like this: HyperLink link = new HyperLink(); link.NavigateUrl = "http://www.page.com"; link.Text = "Some text"; link.ImageUrl="/images/linkimage.gif"; What I would like to do is to show another image for the link on the mouseover event.
0
550
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif images as the ImageURL of the Hyperlink. When a load the page with the controls on it works fine, but sometimes the images are broken, but if i hit refresh i get random selections of the gifs appearing and not appearing. if i hit Back button to a page...
5
6689
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below but here is the snippet of my asp:hyperlink object; <asp:HyperLink NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(Conta iner.DataItem,"CLIENTREF")%> ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,...
8
3800
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...
2
2436
by: Andy | last post by:
Hi, This is one of those things I thought should e easy... I'm programatically trying to set the navigateURL property in a hyperlink in the headertemplate of a repeater, but always get the following error "Object reference not set to an instance of an object." when referencing the hypermink in the following line.. hypAuthors.NavigateUrl = "http://www.microsoft.com"
1
4174
by: MistryP | last post by:
Hey Everyone, I m developing website in ASP.net and i am using Hyperlink control in this website but it is not working in Firefox browser but working in Internet Explorer. My code is: <table border="0" width="1000px"> <tr> <td style="height:20px" align="left"> <asp:Repeater ID ="RepReceipeTitle" runat="server"> <ItemTemplate>
0
9454
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
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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
10039
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
9914
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
7461
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
5355
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...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
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.