views:

32

answers:

2

Okay i have a custom server control that has some autocomplete settings, i have this as follows and it works fine.

    /// <summary>
    /// Auto complete settings
    /// </summary>
    [System.ComponentModel.DesignerSerializationVisibility    (System.ComponentModel.DesignerSerializationVisibility.Content),
    PersistenceMode(PersistenceMode.InnerProperty),
    Category("Data"), Description("Auto complete settings"), NotifyParentProperty(true)]
    public AutoCompleteLookupSettings AutoComplete { private set; get; }

I also have a ParameterCollection that is really related to the auto complete settings, currently this collection resides off the control itself like so :

    /// <summary>
    /// Parameters for any data lookups
    /// </summary>
    [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
    public ParameterCollection Parameters { get; set; }

What i would like to do is move the parameter collection inside of the AutoCompleteSettings as it really relates to my autocomplete, i have tried this but to no avail..

I would like to move from

<cc1:TextField ID="TextField1" runat='server'>
    <AutoComplete MethodName="GetTest" TextField="Item1" TypeName ="AppFrameWork.Utils" />
    <Parameters>
        <asp:ControlParameter ControlID="txtTest" PropertyName="Text" Name="test" />
    </Parameters>
</cc1:TextField>

To

<cc1:TextField ID="TextField1" runat='server'>
    <AutoComplete MethodName="GetTest" TextField="Item1" TypeName ="AppFrameWork.Utils" >
        <Parameters>
            <asp:ControlParameter ControlID="txtTest" PropertyName="Text" Name="test" />
        </Parameters>
    </AutoComplete>
</cc1:TextField>
A: 

In order to do this you need to make the ParameterCollection to be property of the AutoComplete object. I am not 100% sure but the ParameterCollection object declaration might require the

[PersistenceMode(PersistenceMode.InnerProperty)]

attribute. Give it a try ;)

Genady Sergeev
A: 

I think what you're looking for is the ParseChildren attribute.

[ParseChildren(true, "Parameters")]

If you tag your class with this attribute, it will attempt to parse the markup as a child collection, and assign it to a property called "Parameters". There's a good example on the page I linked.

The PersistenceMode attribute as mentioned in another answer is actually to instruct the VS designer to render the child property properly when generating markup. I don't believe it will have the effect you're looking for.

womp
I have tried this but i think since my AutocompleteSettings is a normal class and not a control it doesnt parse the properties, every example i see of this uses a control or webcontrol as the sub-object not a standard class, i dont really want to do this though...
Richard Friend