473,554 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control / Property. Going crazy here.

Hello,

I have a class where I created various controls.
One of the controls have a property which is a generic list of
WebControl.

Then in web site page I have something like:
Dim a As New MyNamespace.Lis tItem
a.WebControls.A dd(tbName)
a.WebControls.A dd(lLabel)
Response.Write( a.WebControls.C ount) >>This returns 0!

When the control renders I can only see its start and end tags.
The controls that I added to it are not rendered into the page.
In fact they seem to not being added to the WebControls property.
(Count returns 0)

I am on this for 2 days. I have no idea what is going on. I tried
everything I could think of!
I think the problem might be in my control property WebControls.

Please, could someone help me out?

Here is my control code:

<DefaultPropert y("ID"), ToolboxData("<{ 0}:Item runat=server></
{0}:Item>")_
Public Class ListItem
Inherits WebControl
Implements INamingContaine r

<Bindable(True) , Category("Setti ngs"), DefaultValue("" ),
Localizable(Tru e)_
Property WebControls() As Generic.List(Of WebControl)
Get
If CStr(ViewState( "WebControl s")) Is Nothing Then
Return New Generic.List(Of WebControl)
Else
Return ViewState("WebC ontrols")
End If
End Get
Set(ByVal Value As Generic.List(Of WebControl))
ViewState("WebC ontrols") = Value
End Set
End Property ' WebControls

' CreateChildCont rols
Protected Overrides Sub CreateChildCont rols()

' Add controls to item
For Each control As WebControl In Me.WebControls
MyBase.Controls .Add(control)
Next ' control

' Create child controls
MyBase.CreateCh ildControls()
Me.ChildControl sCreated = True

End Sub ' CreateChildCont rols

End Class ' List

Thanks,
Miguel

May 28 '07 #1
1 1326
On May 28, 7:38 pm, shapper <mdmo...@gmail. comwrote:
Hello,

I have a class where I created various controls.
One of the controls have a property which is a generic list of
WebControl.

Then in web site page I have something like:
Dim a As New MyNamespace.Lis tItem
a.WebControls.A dd(tbName)
a.WebControls.A dd(lLabel)
Response.Write( a.WebControls.C ount) >>This returns 0!

When the control renders I can only see its start and end tags.
The controls that I added to it are not rendered into the page.
In fact they seem to not being added to the WebControls property.
(Count returns 0)

I am on this for 2 days. I have no idea what is going on. I tried
everything I could think of!
I think the problem might be in my control property WebControls.

Please, could someone help me out?

Here is my control code:

<DefaultPropert y("ID"), ToolboxData("<{ 0}:Item runat=server></
{0}:Item>")_
Public Class ListItem
Inherits WebControl
Implements INamingContaine r

<Bindable(True) , Category("Setti ngs"), DefaultValue("" ),
Localizable(Tru e)_
Property WebControls() As Generic.List(Of WebControl)
Get
If CStr(ViewState( "WebControl s")) Is Nothing Then
Return New Generic.List(Of WebControl)
Else
Return ViewState("WebC ontrols")
End If
End Get
Set(ByVal Value As Generic.List(Of WebControl))
ViewState("WebC ontrols") = Value
End Set
End Property ' WebControls

' CreateChildCont rols
Protected Overrides Sub CreateChildCont rols()

' Add controls to item
For Each control As WebControl In Me.WebControls
MyBase.Controls .Add(control)
Next ' control

' Create child controls
MyBase.CreateCh ildControls()
Me.ChildControl sCreated = True

End Sub ' CreateChildCont rols

End Class ' List

Thanks,
Miguel
Please, anyone?

My full code is as follows:

1
2 <DefaultPropert y("ID"), ToolboxData("<{ 0}:ListItem
runat=server></{0}:ListItem>") _
3 Public Class ListItem
4 Inherits WebControl
5 Implements INamingContaine r
6
7 <Bindable(True) , Category("Setti ngs"), DefaultValue("" ),
Localizable(Tru e)_
8 Property WebControls() As Generic.List(Of WebControl)
9 Get
10 If CStr(ViewState( "WebControl s")) Is Nothing Then
11 Return New Generic.List(Of WebControl)
12 Else
13 Return ViewState("WebC ontrols")
14 End If
15 End Get
16 Set(ByVal Value As Generic.List(Of WebControl))
17 ViewState("WebC ontrols") = Value
18 End Set
19 End Property ' WebControls
20
21 Protected Overrides Sub CreateChildCont rols()
22
23 ' Add controls to item
24 For Each control As WebControl In Me.WebControls
25 MyBase.Controls .Add(control)
26 Next ' control
27
28 ' Create child controls
29 MyBase.CreateCh ildControls()
30 Me.ChildControl sCreated = True
31
32 End Sub ' CreateChildCont rols
33 End Class ' ListItem
34
35 ' List
36 <DefaultPropert y("ID"), ToolboxData("<{ 0}:List runat=server></
{0}:List>")_
37 Public Class List
38 Inherits WebControl
39 Implements INamingContaine r
40
41 ' Items ...
42 <Bindable(True) , Category("Setti ngs"), DefaultValue("" ),
Localizable(Tru e)_
43 Property Items() As Generic.List(Of ListItem)
44 Get
45 If CStr(ViewState( "Items")) Is Nothing Then
46 Return New Generic.List(Of ListItem)
47 Else
48 Return ViewState("Item s")
49 End If
50 End Get
51 Set(ByVal Value As Generic.List(Of ListItem))
52 ViewState("Item ") = Value
53 End Set
54 End Property ' Items
55
56 ' CreateChildCont rols
57 Protected Overrides Sub CreateChildCont rols()
58
59 ' Add controls to item
60 For Each item As ListItem In Me.Items
61 MyBase.Controls .Add(item)
62 Next ' item
63
64 ' Create child controls
65 MyBase.CreateCh ildControls()
66 Me.ChildControl sCreated = True
67
68 End Sub ' CreateChildCont rols
69
70 End Class ' List
Thanks,
Miguel

May 29 '07 #2

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

Similar topics

7
1935
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts the menu is injected into every page at runtime when the page is requested (i.e., it's not declared in any ASPX). The user control contains a menu...
10
5786
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: WebForm1.aspx ChangeValue.aspx WebUserControl1.ascx Module1.vb
5
5939
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an event is fired by one of the controls contained in the User Control, these variable are reset. Here is my current code (I have a little more to add...
3
3723
by: Brent McIntyre | last post by:
Good evening all, I am going crazy with a problem that I am sure has a simple solution. I need to add items to a ComboBox on a Form. I can do it simply when I code on form.vb, but when go to a procedure on a seperate module it says "Name 'ComboBox' is not declared". I have tried setting the modifiers for the ComboBox to Public, Friend...
7
1777
by: BradC | last post by:
(VB.NET 2002, Windows app). I'm going to be provided a two-letter string like "BV" or "TP" that represents a location. I then need to perform some actions on several form controls that have names derived from that location. For example: lblBVimp, txtBVsignoff, txtBVsignoffdate, chkBV Now I know i can do a "For Each XXX in...
6
9378
by: Peter Hartlén | last post by:
Hi! What's the correct syntax for the default value design time attribute, using classdiagram view and Custom Attributes dialog. For a boolean: DefaultValue(true) DefaultValue("true") DefaultValue("bool","true")
15
6491
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then...
0
1342
by: sean worlock | last post by:
Hello all, I have googled like crazy for this with no sucess! I have a dataset containing a table with the following fields Table===Widths --------------------------------------------- WidthID---int (primary key) Width------decimal
0
1936
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in the ini on the client's PC. After the program has ended the control looks in a client side temp folder (specified by the ini file) for an image created...
0
7536
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...
0
7814
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. ...
1
7576
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...
0
7895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5443
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...
0
5165
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...
1
2027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1147
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.