473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTMLAnchor inside a repeater

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.H tmlControls.Htm lAnchor
....

Public Sub haAnchor_Click( ByVal sender As Object, ByVal e As EventArgs)
Handles haAnchor.Server Click
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_Ite mCommand"
EnableViewState ="False" runat="server" DataSource="<%# dvwCustomerDisp lays
%>">
<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_Ite mCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Repe aterCommandEven tArgs) Handles
rpCustomers.Ite mCommand
Me.Label1.Text = "HTML Anchor ItemCommand fired!"
End Sub
=============== =============== ========
Nov 18 '05 #1
3 5680
Hi Leigh,

I'm not clear on what you're aiming to accomplish, but here's what I managed
to do with your code:
<table border="1">
<asp:repeater id="rpCustomers "
OnItemCommand=" rpCustomers_Ite mCommand" EnableViewState ="False"
runat="server">
<itemtemplate >
<tr>
<td>
<a id="haAnchor"
onserverclick=" haAnchor_Click" runat="server"> Click here</a>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</table>
</form>
<p>&nbsp;</p>
<p>
<asp:label id="Label1" runat="server"> Label</asp:label></p>

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim dvwCustomerDisp lays As DataView
dvwCustomerDisp lays = CreateDataSourc e().DefaultView
rpCustomers.Dat aSource = dvwCustomerDisp lays
rpCustomers.Dat aBind()
End Sub

Public Sub haAnchor_Click( ByVal sender As Object, _
ByVal e As System.EventArg s)
Dim htmlAnchor As HtmlAnchor
htmlAnchor = sender
Label1.Text = "HTML Anchor ServerClick fired!" & _
htmlAnchor.Uniq ueID
End Sub

Public Sub rpCustomers_Ite mCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Repe aterCommandEven tArgs) _
Handles rpCustomers.Ite mCommand
Response.Write( e.Item.ItemInde x.ToString)
End Sub

Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce
"Leigh Webber" <Le*********@di scussions.micro soft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
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.H tmlControls.Htm lAnchor
...

Public Sub haAnchor_Click( ByVal sender As Object, ByVal e As EventArgs)
Handles haAnchor.Server Click
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_Ite mCommand"
EnableViewState ="False" runat="server" DataSource="<%# dvwCustomerDisp lays
%>">
<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_Ite mCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Repe aterCommandEven tArgs) Handles
rpCustomers.Ite mCommand
Me.Label1.Text = "HTML Anchor ItemCommand fired!"
End Sub
=============== =============== ========


Nov 18 '05 #2
Thanks, Ken. The problem was that I had omitted the quotation marks around
the repeater's ID attribute. IOW, I had:

<asp:repeater id=rpCustomers ...

when I should have had:

<asp:repeater id="rpCustomers " ...

Sheesh -- can I please have the four hours back I spent chasing my tail on
this one? What a bonehead. :-(

Hmmm -- too bad the syntax checker doesn't pick this one up.

"Ken Cox [Microsoft MVP]" wrote:
Hi Leigh,

I'm not clear on what you're aiming to accomplish, but here's what I managed
to do with your code:
<table border="1">
<asp:repeater id="rpCustomers "
OnItemCommand=" rpCustomers_Ite mCommand" EnableViewState ="False"
runat="server">
<itemtemplate >
<tr>
<td>
<a id="haAnchor"
onserverclick=" haAnchor_Click" runat="server"> Click here</a>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</table>
</form>
<p> </p>
<p>
<asp:label id="Label1" runat="server"> Label</asp:label></p>

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim dvwCustomerDisp lays As DataView
dvwCustomerDisp lays = CreateDataSourc e().DefaultView
rpCustomers.Dat aSource = dvwCustomerDisp lays
rpCustomers.Dat aBind()
End Sub

Public Sub haAnchor_Click( ByVal sender As Object, _
ByVal e As System.EventArg s)
Dim htmlAnchor As HtmlAnchor
htmlAnchor = sender
Label1.Text = "HTML Anchor ServerClick fired!" & _
htmlAnchor.Uniq ueID
End Sub

Public Sub rpCustomers_Ite mCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Repe aterCommandEven tArgs) _
Handles rpCustomers.Ite mCommand
Response.Write( e.Item.ItemInde x.ToString)
End Sub

Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce
"Leigh Webber" <Le*********@di scussions.micro soft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
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.H tmlControls.Htm lAnchor
...

Public Sub haAnchor_Click( ByVal sender As Object, ByVal e As EventArgs)
Handles haAnchor.Server Click
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_Ite mCommand"
EnableViewState ="False" runat="server" DataSource="<%# dvwCustomerDisp lays
%>">
<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_Ite mCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Repe aterCommandEven tArgs) Handles
rpCustomers.Ite mCommand
Me.Label1.Text = "HTML Anchor ItemCommand fired!"
End Sub
=============== =============== ========


Nov 18 '05 #3
Hi Leigh,

Glad to hear you got going. We've all been caught on the small issues -
although I'm surprised the quotes would make a difference there.

BTW, you might want to offer the syntax checker suggestion to Microsoft
here:

http://lab.msdn.microsoft.com/produc...k/default.aspx

Ken
"Leigh Webber" <Le*********@di scussions.micro soft.com> wrote in message
news:51******** *************** ***********@mic rosoft.com...
Thanks, Ken. The problem was that I had omitted the quotation marks around
the repeater's ID attribute. IOW, I had:

<asp:repeater id=rpCustomers ...

when I should have had:

<asp:repeater id="rpCustomers " ...

Sheesh -- can I please have the four hours back I spent chasing my tail on
this one? What a bonehead. :-(

Hmmm -- too bad the syntax checker doesn't pick this one up.

"Ken Cox [Microsoft MVP]" wrote:
Hi Leigh,

I'm not clear on what you're aiming to accomplish, but here's what I
managed
to do with your code:
<table border="1">
<asp:repeater id="rpCustomers "
OnItemCommand=" rpCustomers_Ite mCommand" EnableViewState ="False"
runat="server">
<itemtemplate >
<tr>
<td>
<a id="haAnchor"
onserverclick=" haAnchor_Click" runat="server"> Click here</a>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</table>
</form>
<p> </p>
<p>
<asp:label id="Label1" runat="server"> Label</asp:label></p>

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim dvwCustomerDisp lays As DataView
dvwCustomerDisp lays = CreateDataSourc e().DefaultView
rpCustomers.Dat aSource = dvwCustomerDisp lays
rpCustomers.Dat aBind()
End Sub

Public Sub haAnchor_Click( ByVal sender As Object, _
ByVal e As System.EventArg s)
Dim htmlAnchor As HtmlAnchor
htmlAnchor = sender
Label1.Text = "HTML Anchor ServerClick fired!" & _
htmlAnchor.Uniq ueID
End Sub

Public Sub rpCustomers_Ite mCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Repe aterCommandEven tArgs) _
Handles rpCustomers.Ite mCommand
Response.Write( e.Item.ItemInde x.ToString)
End Sub

Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce
"Leigh Webber" <Le*********@di scussions.micro soft.com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
>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.H tmlControls.Htm lAnchor
> ...
>
> Public Sub haAnchor_Click( ByVal sender As Object, ByVal e As
> EventArgs)
> Handles haAnchor.Server Click
> 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_Ite mCommand"
> EnableViewState ="False" runat="server" DataSource="<%#
> dvwCustomerDisp lays
> %>">
> <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_Ite mCommand(ByVal source As Object, ByVal e As
> System.Web.UI.W ebControls.Repe aterCommandEven tArgs) Handles
> rpCustomers.Ite mCommand
> Me.Label1.Text = "HTML Anchor ItemCommand fired!"
> End Sub
> =============== =============== ========



Nov 18 '05 #4

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

Similar topics

0
2427
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an arbitrary number of empty rows to be added to it. So, if a user knew in advance that they wanted to add 3 phone numbers, they can type the nuber '3' in a textbox (outside the repeater) and click a button (also outside of a repeater), and 3 new empty ...
2
3302
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object reference not set to an instance of an object". This error message commonly occurs when a server control is incorrecly declared, so naturally I have double checked this. To test this, I moved the aspx code for the DataGrid ('myNestedDataGrid')...
7
2000
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to display all of the information. I now have a need to drop this datagrid into a repeater on "Page 2". The repeater will grab ALL orders within a given date range and output the datagrids for each order. Remember, the Page 1 is built to display one...
4
34528
by: huzz | last post by:
I am trying to access a DropDownList control inside a repeater using ItemCommand as shown below but for some reason i can't access the DropDownList. When i step through the debug i get <undefine value> for the DropDownList What am i doing wrong? <asp:Repeater ID="Repeater1" Runat="server" OnItemDataBound="create_ddl" OnItemCommand="Repeater1_ItemCommand"> <HeaderTemplate>
0
1836
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater). Is there any way, we accomplish this? Any advice on this would be greatly appreciated. Reza. ---BEGIN PART Of ListApp.aspx --->
8
3026
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
0
4094
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me that my second repeater has the following error, System.NullReferenceException: Object reference not set to an instance of an object. When I put a watch on I can see my second repeater is not being created because it is equal to "Nothing". I can...
1
7354
by: champ.supernova | last post by:
Hi, I have a dropdownlist which is repeated inside a repeater. What I'm wanting is for when one instance of the dropdownlist has its selection changed, for 1) this to trigger an 'OnSelectedIndexChanged' subroutine, and 2) for that subroutine to be able to somehow identify which 'row' of the repeater the dropdownlist belongs to. To keep things simple, I'm posting just the relevant parts of the code below...
1
1945
by: Řyvind Isaksen | last post by:
I need to know how to handle controls inside a repeater, how to send and recieve data from another page to one spesific control inside a repeater. Clue: I have a repeater that dynamicly lists out different kind of webcontrols (based on some criterias). Each textboxes inside the repeater need to have a "browse" button, when clicking that button another page shall open (popup) and the user can bwrowse for some content to insert. When...
0
9790
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
9779
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
9645
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...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7186
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
5069
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...
1
3742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2612
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.