B
Bill E.
ASP.NET 3.5
I have a repeater generating table rows containing a hiddenfield, a
simple control (textbox) and a usercontrol (mycontrol). I am using
the repeater ItemCreated event to attach event handlers for the
textbox and the usercontrol:
Protected Sub rpt1_ItemCreated(ByVal obj As Object, ByVal e As
RepeaterItemEventArgs)
'Add event handlers
Dim tbValue As TextBox = DirectCast(e.Item.FindControl
("tbValue"), TextBox)
AddHandler tbValue.TextChanged, AddressOf ValueChanged
Dim dtValue As ASP.controls_mycontrol_ascx = DirectCast
(e.Item.FindControl("dtValue"), ASP.controls_mycontrol_ascx)
AddHandler dtValue.Changed, AddressOf ValueChanged
End Sub
The event handler ValueChanged is firing correctly, but when it fires
for the usercontrol, I am unable to use FindControl to locate the
hidden field. When it fires for the textbox, the hidden field is
found successfully:
Protected Sub ValueChanged(ByVal obj As Object, ByVal e As
EventArgs)
'Handle changes to control values
'Get the identifier of the element
Dim FieldID As Integer
Try
Dim tbid As HiddenField = obj.FindControl("tbid")
FieldID = Convert.ToInt32(tbid.Value)
Catch ex As Exception
'This is done because we can't seem to use FindControl to
find tbid from the datebox.
Response.Write("Can't find the hidden field")
End Try
End Sub
Does anyone know why FindControl is failing when the event fires for
the usercontrol but not for the textbox?
Thanks,
Bill E.
Hollywood, FL
I have a repeater generating table rows containing a hiddenfield, a
simple control (textbox) and a usercontrol (mycontrol). I am using
the repeater ItemCreated event to attach event handlers for the
textbox and the usercontrol:
Protected Sub rpt1_ItemCreated(ByVal obj As Object, ByVal e As
RepeaterItemEventArgs)
'Add event handlers
Dim tbValue As TextBox = DirectCast(e.Item.FindControl
("tbValue"), TextBox)
AddHandler tbValue.TextChanged, AddressOf ValueChanged
Dim dtValue As ASP.controls_mycontrol_ascx = DirectCast
(e.Item.FindControl("dtValue"), ASP.controls_mycontrol_ascx)
AddHandler dtValue.Changed, AddressOf ValueChanged
End Sub
The event handler ValueChanged is firing correctly, but when it fires
for the usercontrol, I am unable to use FindControl to locate the
hidden field. When it fires for the textbox, the hidden field is
found successfully:
Protected Sub ValueChanged(ByVal obj As Object, ByVal e As
EventArgs)
'Handle changes to control values
'Get the identifier of the element
Dim FieldID As Integer
Try
Dim tbid As HiddenField = obj.FindControl("tbid")
FieldID = Convert.ToInt32(tbid.Value)
Catch ex As Exception
'This is done because we can't seem to use FindControl to
find tbid from the datebox.
Response.Write("Can't find the hidden field")
End Try
End Sub
Does anyone know why FindControl is failing when the event fires for
the usercontrol but not for the textbox?
Thanks,
Bill E.
Hollywood, FL