Problem with collection property in custom server control

Tech-Archive recommends: Fix windows errors by optimizing your registry



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(DesignerSerializationVisibility.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é


.



Relevant Pages

  • English eBooks Engineering
    ... Adaptive Voltage Control in Power Systems Fusco, ... Advanced Design Techniques for RF Power Amplifiers Krizhanovski, ... Advanced Fuzzy Logic Technologies in Industrial Applications Bai, ... Bioinformatics Using Computational Intelligence Paradigms Jain, ...
    (sci.med.nutrition)
  • Re: Microchip programmer Sydney Aus
    ... schematic design, embedded firmware and pcb layout to finished product. ... possible through the use of advanced microcontroller products from Microchip ... microcontroller applications in Innovative Power and Control solutions. ... Resources cover a broad range of electronics ...
    (sci.electronics.design)
  • Ebooks Forum
    ... Analysis and Design of Advanced Multiservice Networks Supporting ... Control and Observer Design for Nonlinear Finite and Infinite ... IUTAM Symposium on Computational Approaches to Multiphase Flow ... Islamic Philosophy and Occidental Phenomenology on the Perennial Issue ...
    (sci.med.nutrition)
  • a forum for you
    ... Advances in High Performance Computing and Computational Sciences ... Analysis and Design of Advanced Multiservice Networks Supporting ... Control and Observer Design for Nonlinear Finite and Infinite ... IUTAM Symposium on Computational Approaches to Multiphase Flow ...
    (sci.med.nutrition)
  • English eBooks Engineering
    ... Advances in High Performance Computing and Computational Sciences ... Analysis and Design of Advanced Multiservice Networks Supporting ... Control and Observer Design for Nonlinear Finite and Infinite ... IUTAM Symposium on Computational Approaches to Multiphase Flow ...
    (sci.med.nutrition)