The repeater fires the event when Item is created
Protected Sub Repeater1_ItemCreated(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemCreated
And it is possible to catch and modify the control on this single data row.
Dim lnk As HyperLink = CType(e.Item.FindControl("lblShipmentDetails"), HyperLink)
Now the problem is, that for any JavaScript, it is needed to determine the correct client ID. But the control does not hold the Client ID, just the lblShipmentDetails
String.
What MSDN says:
https://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/1d04y8ss%28v=vs.140%29.aspx
or CodeProject:
http://www.codeproject.com/Articles/108887/Client-Ids-Generation-with-ASP-NET
But how to catch the correct ClientID from Repeater to use it in JavaScript ?
Source is generated with auto-id. How to get this id?
Use DataBound
Event. To get the control ID, the repeater needs to bind data first. Then just ask for ID as in the Created
event.
Protected Sub Repeater1_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim btn As Button = CType(e.Item.FindControl("btnOrderTrackingConfirmMove"), Button)
If btn IsNot Nothing Then
Dim RealId As String = btn.Page.ClientScript.GetPostBackEventReference(btn, String.Empty).ToString
End If
End If
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With