web control properties with child poperties in designer...

Discussion in 'ASP .Net Web Controls' started by Klaus Salchner, Mar 3, 2004.

  1. I have two issues with properties of a web control (like a class) which have
    sub-properties. I want to be able to show these sub-properties on the
    property designer so that the user can change the property values through
    the designer:

    (a) I create my won class like Address which has a Text and Description
    property. These properties have the get/set accessors. Then I have a
    property of the type Address on my control itself, again with the get/set
    accessors. I see the property on the designer, but it is read-only and the
    value is set to the type, e.g. MyControl.PropertyName.

    // PlayerAddress is a complex property whose
    // type is the class Address. Address has four
    // properties, Street, City, State, and Zip. These become
    // subproperties of SoccerPlayer.
    public Address PlayerAddress
    {
    get
    {
    return address;
    }
    }

    (b) I have a composite control which has added childs, like a text control.
    Now I exposed a property TextFont on my control with a get/set accessor. It
    gets/sets the Font property of the text child control. I can see the font on
    the property designer, I can set the values, but they are not persistent. I
    do not see any HTML tags created and when I close the page and open it again
    all the settings are lost. But when I change them I see the rendering on the
    designer change accordingly.

    /// <summary>
    /// the font to use for the tool box description
    /// </summary>
    [Browsable(true),
    Category("ToolBoxItemAppearance"),
    Description("The font of the description control.")]
    public FontInfo DescriptionFont
    {
    get
    {
    // makes sure that all the client controls are created as we need to
    get a reference
    // to the font property of the description control
    EnsureChildControls();

    // returs the font of the description label
    return TheDescriptionLabel.Font;
    }
    }

    So there is something I am doing wrong here. And I can't find any workable
    example. Even the example provided in the documentation shows the behavior
    described in point (a).

    Any help is greatly appreciated. Even if it just pointing to a working
    sample so I can figure out what I need to do.

    Also in case some MS guys read this. When it comes to web controls and the
    more advanced thing you can do - I unfortunately I have to say the
    documentation is lacking - lacking in a big way!

    Regards, Klaus
    -----------------------------------------------
    Klaus Salchner
    email:

    Proud member of
    http://linkedin.com - become part of my professional network; it's a free
    3rd party tool
    http://gotdotnet.com
    http://theserverside.net
     
    Klaus Salchner, Mar 3, 2004
    #1
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.