S
shapper
Hello,
I have a control with the following property:
Private _Sections As New List(Of FormSection)
Public Property Sections() As List(Of FormSection)
Get
If _Sections Is Nothing Then
_Sections = New List(Of FormSection)
End If
Return _Sections
End Get
Set(ByVal value As List(Of FormSection))
_Sections = value
End Set
End Property
FormSection is another custom control. My control inherits from
CompositeControl and I implement it as follows:
Protected Overrides Sub CreateChildControls()
For Each section As FormSection In Me.Sections
MyBase.Controls.Add(section)
Next
MyBase.CreateChildControls()
End Sub
Finally I need to run a method from a child control in each section
when a Bubble event is caught:
Protected Overrides Function OnBubbleEvent(ByVal source As Object,
ByVal e As EventArgs) As Boolean
If TypeOf e Is CommandEventArgs Then
For Each section In Me.Sections
For Each field In section.Fields
If Not field.Validate Then
' Stop bubbling for EventArgs
Return True
End If
Next field
Next section
OnCommand(e)
End If
' Let bubbling run for non CommandEventArgs
Return False
End Function
The problem is that Me.Sections has no section in it so the loop does
not run.
But the sections are there! I added them and when I run the page I see
all them.
What am I doing wrong?
Thanks,
Miguel
I have a control with the following property:
Private _Sections As New List(Of FormSection)
Public Property Sections() As List(Of FormSection)
Get
If _Sections Is Nothing Then
_Sections = New List(Of FormSection)
End If
Return _Sections
End Get
Set(ByVal value As List(Of FormSection))
_Sections = value
End Set
End Property
FormSection is another custom control. My control inherits from
CompositeControl and I implement it as follows:
Protected Overrides Sub CreateChildControls()
For Each section As FormSection In Me.Sections
MyBase.Controls.Add(section)
Next
MyBase.CreateChildControls()
End Sub
Finally I need to run a method from a child control in each section
when a Bubble event is caught:
Protected Overrides Function OnBubbleEvent(ByVal source As Object,
ByVal e As EventArgs) As Boolean
If TypeOf e Is CommandEventArgs Then
For Each section In Me.Sections
For Each field In section.Fields
If Not field.Validate Then
' Stop bubbling for EventArgs
Return True
End If
Next field
Next section
OnCommand(e)
End If
' Let bubbling run for non CommandEventArgs
Return False
End Function
The problem is that Me.Sections has no section in it so the loop does
not run.
But the sections are there! I added them and when I run the page I see
all them.
What am I doing wrong?
Thanks,
Miguel