473,769 Members | 2,102 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 1347
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
1942
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 that is dynamically populated and styled at runtime (fwiw: it's ComponentArt's Menu for ASP.NET -...
10
5823
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
5991
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 later, right now I am just concerned about the variables getting reset): Public Class DatePicker2...
3
3736
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 and Private all to no avail. I am also not sure why on the main page "Me." is used before a...
7
1785
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 myForm.Controls", If XXX.name = blahblahblah,
6
9384
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
6521
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 i added this line "" before my custom control class (i dont know what this line does). Now
0
1355
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
1975
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 by the executed program. If the image is there, then the control moves the file to a public folder...
0
9579
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
9422
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,...
1
9987
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,...
0
9857
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
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
6662
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
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3558
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.