Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Property missing value

Reply
Thread Tools

Property missing value

 
 
shapper
Guest
Posts: n/a
 
      02-25-2008
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
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      02-25-2008
The OnBubbleEvent method is called prior to the CreateChildControls method
in the Control lifecycle.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"shapper" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      02-25-2008
On Feb 25, 11:41 am, "Kevin Spencer" <unclechutney@localhost> wrote:
> The OnBubbleEvent method is called prior to the CreateChildControls method
> in the Control lifecycle.
>
> --
> HTH,
>
> Kevin Spencer
> Chicken Salad Surgeon
> Microsoft MVP
>
> "shapper" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > 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


So there is no solution to this?
How is this usually done? Any idea?

Basically, I need to stop the event if the Section controls do not
validate ...

Thanks,
Miguel
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      02-25-2008
in OnBubbleEvent, before accessing any child controls, call
EnsureChildControls().

-- bruce (sqlwork.com)


"shapper" wrote:

> On Feb 25, 11:41 am, "Kevin Spencer" <unclechutney@localhost> wrote:
> > The OnBubbleEvent method is called prior to the CreateChildControls method
> > in the Control lifecycle.
> >
> > --
> > HTH,
> >
> > Kevin Spencer
> > Chicken Salad Surgeon
> > Microsoft MVP
> >
> > "shapper" <(E-Mail Removed)> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> > > 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

>
> So there is no solution to this?
> How is this usually done? Any idea?
>
> Basically, I need to stop the event if the Section controls do not
> validate ...
>
> Thanks,
> Miguel
>

 
Reply With Quote
 
shapper
Guest
Posts: n/a
 
      02-27-2008
On Feb 25, 4:44 pm, bruce barker
<(E-Mail Removed)> wrote:
> in OnBubbleEvent, before accessing any child controls, call
> EnsureChildControls().
>
> -- bruce (sqlwork.com)
>
> "shapper" wrote:
> > On Feb 25, 11:41 am, "Kevin Spencer" <unclechutney@localhost> wrote:
> > > The OnBubbleEvent method is called prior to the CreateChildControls method
> > > in the Control lifecycle.

>
> > > --
> > > HTH,

>
> > > Kevin Spencer
> > > Chicken Salad Surgeon
> > > Microsoft MVP

>
> > > "shapper" <(E-Mail Removed)> wrote in message

>
> > >news:(E-Mail Removed)...

>
> > > > 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

>
> > So there is no solution to this?
> > How is this usually done? Any idea?

>
> > Basically, I need to stop the event if the Section controls do not
> > validate ...

>
> > Thanks,
> > Miguel


I tried but it does not work.

Any idea?

Thanks,
Miguel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<value> could not be set on property <property name> TonyDyer General Computer Support 0 02-14-2012 03:25 PM
Property File - property value break on multiple line Dev_SH Java 0 12-30-2010 09:34 AM
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
Find value of SELECT if VALUE attribute is missing Matt Kruse Javascript 4 01-08-2007 09:03 PM
'property value' could not be set on property 'propertyname' KJ ASP .Net Web Controls 0 08-26-2003 06:08 PM



Advertisments