473,975 Members | 21,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Property is empty. Why?

Hello,

I am creating a custom control, named Form, which inherits from
CompositeContro l.

I am adding child custom controls, named Section, to the Form through
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 ' Sections

Then I build my control as follows:

Protected Overrides Sub CreateChildCont rols()
For Each section As FormSection In Me.Sections
MyBase.Controls .Add(section)
Next ' section
MyBase.CreateCh ildControls()
End Sub

However, in OnBubbleEvent, which I am overriding, Me.Sections count 0
while Me.Controls count 4, the number of controls I added:

Protected Overrides Function OnBubbleEvent(B yVal source As Object,
ByVal e As EventArgs) As Boolean
Dim c As ControlCollecti on = Me.Controls
Dim s As List(Of FormSection) = Me.Sections
End sub

Why?

I was using a Loop with Me.Sections and it was not working and now I
found out why.

What am I doing wrong?

Thanks,

Miguel
Feb 23 '08 #1
2 939
when do you ever add a section to the control? do you do it on postback?

-- bruce (sqlwork.com)

shapper wrote:
Hello,

I am creating a custom control, named Form, which inherits from
CompositeContro l.

I am adding child custom controls, named Section, to the Form through
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 ' Sections

Then I build my control as follows:

Protected Overrides Sub CreateChildCont rols()
For Each section As FormSection In Me.Sections
MyBase.Controls .Add(section)
Next ' section
MyBase.CreateCh ildControls()
End Sub

However, in OnBubbleEvent, which I am overriding, Me.Sections count 0
while Me.Controls count 4, the number of controls I added:

Protected Overrides Function OnBubbleEvent(B yVal source As Object,
ByVal e As EventArgs) As Boolean
Dim c As ControlCollecti on = Me.Controls
Dim s As List(Of FormSection) = Me.Sections
End sub

Why?

I was using a Loop with Me.Sections and it was not working and now I
found out why.

What am I doing wrong?

Thanks,

Miguel
Feb 23 '08 #2
On Feb 23, 7:43 pm, bruce barker <nos...@nospam. comwrote:
when do you ever add a section to the control? do you do it on postback?

-- bruce (sqlwork.com)

shapper wrote:
Hello,
I am creating a custom control, named Form, which inherits from
CompositeContro l.
I am adding child custom controls, named Section, to the Form through
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 ' Sections
Then I build my control as follows:
Protected Overrides Sub CreateChildCont rols()
For Each section As FormSection In Me.Sections
MyBase.Controls .Add(section)
Next ' section
MyBase.CreateCh ildControls()
End Sub
However, in OnBubbleEvent, which I am overriding, Me.Sections count 0
while Me.Controls count 4, the number of controls I added:
Protected Overrides Function OnBubbleEvent(B yVal source As Object,
ByVal e As EventArgs) As Boolean
Dim c As ControlCollecti on = Me.Controls
Dim s As List(Of FormSection) = Me.Sections
End sub
Why?
I was using a Loop with Me.Sections and it was not working and now I
found out why.
What am I doing wrong?
Thanks,
Miguel
I do it on Page_Init when I am adding controls to the page.
Feb 23 '08 #3

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

Similar topics

5
2922
by: Secret Guy | last post by:
Because of my experience posting various places over the last couple of weeks: I'm expecting to be greated with hostility for asking about concepts instead of "practical" things, since that has been my experience for years and decades. Maybe I'm projecting hostility. I don't know. How can I ask about theory and concepts without offending people? I'll just continue asking and cross my fingers: According to the 2.1 spec, regarding...
2
6811
by: Robert Oschler | last post by:
I have Javascript code that clears the SRC property of an IFRAME during the onload event of a web page, if a certain flag is set. In Mozilla/FireFox the clearing of the SRC property works fine and the browser does not attempt to load the document. That document being the one that was specified in the SRC property, before it was erased. In Internet Explorer, the code appears to clear the SRC property properly. If I trace the code, the...
4
2003
by: JollyK | last post by:
Hello folks, Suppose I have a property called SortField string SortField { get { if (SortField == string.Empty) {
3
3586
by: Tom | last post by:
I am having trouble serializing a color property. Basically, it is not serializing the value. For instance, in the following: <Serializable()> _ Public Class TestColor Private _MyColor As System.Drawing.Color = System.Drawing.Color.Red Public Property MyColor() As System.Drawing.Color Get Return _MyColor
37
2632
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
2
9774
by: Ben Voigt | last post by:
The C# Language Specification says: A virtual property declaration specifies that the accessors of the property are virtual. The virtual modifier applies to both accessors of a read-write property - it is not possible for only one accessor of a read-write property to be virtual. An abstract property declaration specifies that the accessors of the property are virtual, but does not provide an actual implementation of the accessors....
2
8491
by: rn5a | last post by:
The different Validation controls like RequiredFieldValidator, RangeValidator etc. have a property named Display. This property can have 3 values - Dynamic, Static & None. What's the difference between the Dynamic Display & Static Display? Also suppose a Form has 2 TextBoxes & both the TextBoxes have the RequiredFieldValidator. The Form has a Button as well. <form runat="server"> First Name: <asp:TextBox ID="txtFName" runat="server"/>
3
1280
by: | last post by:
wHen i set CokSatan in my page load event it returns stack overflow.. When i try it step by step it stucks at this.CokSatan = value; line. what is the problem ?
18
2208
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the SelectedIndex to -1. Do you have any suggestion for getting around this problem?
5
2026
by: Berryl Hesh | last post by:
Is there a way to pass a property around as a parameter without reflection? My current motivation for this is the code below is testing multiple properties to see that an exception is thrown if a user tries to set the string value to an empty value. Ideally I'd like to have one method that would take a Property as a parameter and test it: public void CompanyName_Error_CannotSetToEmpty() { var customer = new Customer { ID = "TEST" };
0
10348
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10161
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11404
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
11564
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,...
1
8454
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
7601
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6547
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.