Collections properties in custom controls

Discussion in 'ASP .Net Building Controls' started by Roberto Ferreira, Apr 17, 2006.

  1. Hi, How I can create collections properties in my custom controls in ASP.net
    (C#), I need create properties inside other propierties. Thanks! My english
    is bad, excuse me!
     
    Roberto Ferreira, Apr 17, 2006
    #1
    1. Advertising

  2. Roberto Ferreira

    CMM Guest

    Apparently this is not possible with UserControls (well, you can, but they
    can't be edited via the Property Editor in the Designer). For Custom
    Controls (derived or composite) you can try decorating your collection
    property as so:

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
    PersistenceMode(PersistenceMode.InnerProperty), _
    NotifyParentProperty(True)> _
    Public ReadOnly Property MyItems() As ...

    And pray a little.

    P.S. Custom controls (Derived, Composite, or User) ABSOLUTELY SUCK in
    ASP.NET 2.0.


    --
    -C. Moya
    www.cmoya.com
    "Roberto Ferreira" <> wrote in message
    news:...
    > Hi, How I can create collections properties in my custom controls in
    > ASP.net (C#), I need create properties inside other propierties. Thanks!
    > My english is bad, excuse me!
    >
    >
    >
     
    CMM, Apr 18, 2006
    #2
    1. Advertising

  3. hi roberto, first you need to create your collection class, this will be the
    type of your property in your custom control. If you need to know how to
    define a collection class, take a look at the following documentation on
    msdn.
    http://msdn2.microsoft.com/en-US/library/system.collections.collectionbase.aspx

    Once you have this defined, make a public property in your custom control
    with a getter accessor only. No setter =P
    Ok, another thing i'm not clear with is when you say property of a property
    ? It seems to me you do not want a collection property but a property with a
    complex type. If this is the case then instead of a collection class you can
    have a normal class and this will be the type of your property.

    A good, full working example for collection properties is also available on
    msdn articles, take a look :
    http://msdn2.microsoft.com/en-us/library/9txe1d4x(VS.80).aspx
    Even though this one uses an arraylist(simplicity at its best), its a good
    example and gives you a good idea on how to proceed.

    If you are still confused, feel free to ask.
    Have a good day,

    Alessandro Zifiglio
    "CMM" <> ha scritto nel messaggio
    news:%23tbw$...
    > Apparently this is not possible with UserControls (well, you can, but they
    > can't be edited via the Property Editor in the Designer). For Custom
    > Controls (derived or composite) you can try decorating your collection
    > property as so:
    >
    > <DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    > _
    > PersistenceMode(PersistenceMode.InnerProperty), _
    > NotifyParentProperty(True)> _
    > Public ReadOnly Property MyItems() As ...
    >
    > And pray a little.
    >
    > P.S. Custom controls (Derived, Composite, or User) ABSOLUTELY SUCK in
    > ASP.NET 2.0.
    >
    >
    > --
    > -C. Moya
    > www.cmoya.com
    > "Roberto Ferreira" <> wrote in message
    > news:...
    >> Hi, How I can create collections properties in my custom controls in
    >> ASP.net (C#), I need create properties inside other propierties. Thanks!
    >> My english is bad, excuse me!
    >>
    >>
    >>

    >
    >
     
    Alessandro Zifiglio, Apr 19, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ABC
    Replies:
    0
    Views:
    492
  2. Doug Poland
    Replies:
    9
    Views:
    744
    VisionSet
    Sep 27, 2003
  3. mutex
    Replies:
    0
    Views:
    219
    mutex
    Jul 27, 2003
  4. Moldy

    Accessing Properties of Custom Controls child Controls

    Moldy, Sep 4, 2003, in forum: ASP .Net Building Controls
    Replies:
    8
    Views:
    234
    Moldy
    Sep 5, 2003
  5. ABC
    Replies:
    0
    Views:
    226
Loading...

Share This Page