473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with collection property in custom server control

Hi,
I've created a server control (it inherits from WebControl) wich has a
property of genertic collection type.
The type of the generic collection is NavigationItem, a little class I've
created...

The declaration of the collection property is that:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public Collection<NavigationItem> Items
{
get
{
if (_items == null)
_items = new Collection<NavigationItem>();
return _items;
}
}

If I put the control on my ASPX page, the control renders fine. Also when I
create some items in that collection everything looks good.
When I change from from the design view to the source view, the tags for my
control looks like this:

<ctrls:TopNavigationPanel ID="TopNavigationPanel1" runat="server"
BackgroundUrl="img/bg_horizontal.gif">
<Items>
<ctrls:NavigationItem ControlText="My item" Selected="False" />
<ctrls:NavigationItem ControlText="My second item"
Selected="False" />
</Items>

Now if I change back to the design view, instead of my control I can see the
following error message:

'Items' could not be initialized. Details: 'Items' could not be added to the
collection. Details: The value "Controls.NavigationItem" is not of type
"Controls.NavigationItem" and cannot be used in this generic collection.
Parameter name: value

If I remove the items in the source view the control is displayed correctly
in the design view.
When I start my website the control also looks good, with or without items
in the collection. Only the Designer seems to dislikes this property if it
has items.

If I override the ToString method of the NavigationItem class and return
this.ControlText (ControlText is a string property of the NavigationItem
class) the error message in the design view changes to that:

[...] Details: The value "My item" is not of type "Controls.NavigationItem"
[...].

So I think the designer tries to add something wrong to the collection and
that fails... but I don't know, where I have made a mistake.

Maybe anyone of you can help me with that...?

I'm using Visual Studio 2005 Beta 2.

Thank you very much!
René
Dec 7 '05 #1
0 1323

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

Similar topics

2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
3
by: Eric | last post by:
I have built a composite user web control that I want to create dynamically. The form will contain a variable number of these controls and as well some of the contents of the user web control...
0
by: michael | last post by:
Hi. I have a problem using the CollectioEditor. In my custom control I have a public property that returns ItemList. ItemList is inherited from CollectionBase and contains very simple items...
0
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
0
by: A.J. van der Burg | last post by:
Hi all, I have a serious problem with asp.net validation: I developed a custom validation summary control, which will lookup error messages from an external source based on the...
1
by: aidancasey | last post by:
I have written a custom control called CheckboxDataList that derives from the DataList webControl. My control contains a public property called CheckedValues. The type of this property is a...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
0
by: Harlan Messinger | last post by:
Suppose I have a collection class MyCollection (which implements IList) a custom web control class MyControl that includes a property Items of type MyCollection that will contain objects of class...
12
by: Ron M. Newman | last post by:
Hi, I can load an assembly using the Assembly.Load(....) However, I'd like dynamic loading of assemblies to be identical to putting an assembly reference in your VS2005 project. and yes, I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.