P
Patrick.O.Ige
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:hand"
onmouseover="style.backgroundColor='#c0c0c0';"
onmouseout="style.backgroundColor=''" bordercolor="#000000">
<td>
<asp:Image id="Image1" runat="server"
ImageUrl="images/off.gif"></asp:Image>
<asp:HyperLink CssClass="a" id="HyperLink1" Text='<%#
DataBinder.Eval(Container.DataItem, "cat_cities") %>' NavigateUrl='<%#
"template2.aspx?CategoryID=" & DataBinder.Eval(Container.DataItem, "catid")
%>' runat="server" />
</td>
</tr>
</ItemTemplate>
And in the repeater i did:-
Sub Repeater_ItemCreated(ByVal sender As Object, ByVal e As
RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim hyperLink As HyperLink =
CType(e.Item.FindControl("HyperLink1"), HyperLink)
Dim Image As System.Web.UI.WebControls.Image =
CType(e.Item.FindControl("Image1"), System.Web.UI.WebControls.Image)
hyperLink.Attributes.Add("onMouseOver", Image.ClientID &
".src='images/up.gif';return true;")
hyperLink.Attributes.Add("onMouseOut", Image.ClientID &
".src='images/off.gif'; return true;")
End If
End Sub
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:hand"
onmouseover="style.backgroundColor='#c0c0c0';"
onmouseout="style.backgroundColor=''" bordercolor="#000000">
<td>
<asp:Image id="Image1" runat="server"
ImageUrl="images/off.gif"></asp:Image>
<asp:HyperLink CssClass="a" id="HyperLink1" Text='<%#
DataBinder.Eval(Container.DataItem, "cat_cities") %>' NavigateUrl='<%#
"template2.aspx?CategoryID=" & DataBinder.Eval(Container.DataItem, "catid")
%>' runat="server" />
</td>
</tr>
</ItemTemplate>
And in the repeater i did:-
Sub Repeater_ItemCreated(ByVal sender As Object, ByVal e As
RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim hyperLink As HyperLink =
CType(e.Item.FindControl("HyperLink1"), HyperLink)
Dim Image As System.Web.UI.WebControls.Image =
CType(e.Item.FindControl("Image1"), System.Web.UI.WebControls.Image)
hyperLink.Attributes.Add("onMouseOver", Image.ClientID &
".src='images/up.gif';return true;")
hyperLink.Attributes.Add("onMouseOut", Image.ClientID &
".src='images/off.gif'; return true;")
End If
End Sub