G
Guest
I have an HTMLAnchor control on my aspx page. When it's not inside a
repeater, it works fine. When I put it inside a repeater control, the handler
never gets fired. I have a handler for the htmlAnchor's ServerClick event
(works when not inside a repeater), and a handler for the repeater's
ItemCommand event. My html and vb source code is shown below, but what I
think I need is a simple working example in vb.net. Can anyone help?
======================================
<a ID="haAnchor" OnServerClick="haAnchor_Click" runat="server">Click here</a>
======================================
In my code behind:
======================================
....
Protected WithEvents haAnchor As System.Web.UI.HtmlControls.HtmlAnchor
....
Public Sub haAnchor_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles haAnchor.ServerClick
Me.Label1.Text = "HTML Anchor ServerClick fired!"
End Sub
======================================
When I put my HTMLAnchor control inside a repeater, the ServerClick event
does not fire:
=========================================
<table>
<asp:Repeater id=rpCustomers OnItemCommand="rpCustomers_ItemCommand"
EnableViewState="False" runat="server" DataSource="<%# dvwCustomerDisplays
%>">
<ItemTemplate>
<tr>
<td>
<a ID="haAnchor" OnServerClick="haAnchor_Click" runat="server">Click
here</a>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
=====================================
In my code behind, I have the same handler as before, plus this one:
=====================================
Public Sub rpCustomers_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles
rpCustomers.ItemCommand
Me.Label1.Text = "HTML Anchor ItemCommand fired!"
End Sub
======================================
repeater, it works fine. When I put it inside a repeater control, the handler
never gets fired. I have a handler for the htmlAnchor's ServerClick event
(works when not inside a repeater), and a handler for the repeater's
ItemCommand event. My html and vb source code is shown below, but what I
think I need is a simple working example in vb.net. Can anyone help?
======================================
<a ID="haAnchor" OnServerClick="haAnchor_Click" runat="server">Click here</a>
======================================
In my code behind:
======================================
....
Protected WithEvents haAnchor As System.Web.UI.HtmlControls.HtmlAnchor
....
Public Sub haAnchor_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles haAnchor.ServerClick
Me.Label1.Text = "HTML Anchor ServerClick fired!"
End Sub
======================================
When I put my HTMLAnchor control inside a repeater, the ServerClick event
does not fire:
=========================================
<table>
<asp:Repeater id=rpCustomers OnItemCommand="rpCustomers_ItemCommand"
EnableViewState="False" runat="server" DataSource="<%# dvwCustomerDisplays
%>">
<ItemTemplate>
<tr>
<td>
<a ID="haAnchor" OnServerClick="haAnchor_Click" runat="server">Click
here</a>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
=====================================
In my code behind, I have the same handler as before, plus this one:
=====================================
Public Sub rpCustomers_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles
rpCustomers.ItemCommand
Me.Label1.Text = "HTML Anchor ItemCommand fired!"
End Sub
======================================