Home All Groups Group Topic Archive Search About
Author
3 Jan 2006 9:19 PM
Ashish
Hi all,
Iam trying to design a web server control using asp.net 2.0, that has a
collection exposed. so that user can specify list elements in the markup.

like

<uc1:MyControl id="Mycontrol1" runat="server" property1="value">
   <Item name="value" prop1="value"></Item>
</uc1:MyControl>

wondering if the item class has to be a control too, and how should i
expose this collection so that asp.net realizes this as a valid markup,
and populates the objects at page load...


any help would be appreciated.

TIA

Author
3 Jan 2006 9:47 PM
Keith Patrick
Check out the ParseChildrenAttribute class.  That affects how your class is
deserialized (parsed) by the asp engine such that you can handle child
elements differently than the default.  The default behavior, I believe, is
to attempt to add them as children of the Controls collection, in which
case, a) it would need to be a control, and b) you'd need to qualify it with
a tagname so that the engine knows what type to deserialize the markup to.
Author
3 Jan 2006 11:47 PM
Ashish
Thanks Keith,

i found an example of a control at by using ControlBuilder class on
http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx#builder

I did exactly as mentioned in the sample by defining three classes, one
for the main control, one for the child control, and one for the
ControlBuilder, and then by decorating the main control class with the
derived ControlBuilder


but now the XHTML validator throws error saying that child element not
supported !, and would show object reference error on the design view of
the form

am i missing anything ?

thanks for your help again








Keith Patrick wrote:
Show quoteHide quote
> Check out the ParseChildrenAttribute class.  That affects how your class is
> deserialized (parsed) by the asp engine such that you can handle child
> elements differently than the default.  The default behavior, I believe, is
> to attempt to add them as children of the Controls collection, in which
> case, a) it would need to be a control, and b) you'd need to qualify it with
> a tagname so that the engine knows what type to deserialize the markup to.
>
>
Author
3 Jan 2006 11:52 PM
Ashish
never mind i found out what the problem was :)


Ashish wrote:
Show quoteHide quote
> Thanks Keith,
>
> i found an example of a control at by using ControlBuilder class on
> http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx#builder
>
>
> I did exactly as mentioned in the sample by defining three classes, one
> for the main control, one for the child control, and one for the
> ControlBuilder, and then by decorating the main control class with the
> derived ControlBuilder
>
>
> but now the XHTML validator throws error saying that child element not
> supported !, and would show object reference error on the design view of
> the form
>
> am i missing anything ?
>
> thanks for your help again
>
>
>
>
>
>
>
>
> Keith Patrick wrote:
>
>> Check out the ParseChildrenAttribute class.  That affects how your
>> class is deserialized (parsed) by the asp engine such that you can
>> handle child elements differently than the default.  The default
>> behavior, I believe, is to attempt to add them as children of the
>> Controls collection, in which case, a) it would need to be a control,
>> and b) you'd need to qualify it with a tagname so that the engine
>> knows what type to deserialize the markup to.
>>
Author
3 Jan 2006 11:53 PM
Ashish
never mind i found out what the problem was :)


Ashish wrote:
Show quoteHide quote
> Thanks Keith,
>
> i found an example of a control at by using ControlBuilder class on
> http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx#builder
>
>
> I did exactly as mentioned in the sample by defining three classes, one
> for the main control, one for the child control, and one for the
> ControlBuilder, and then by decorating the main control class with the
> derived ControlBuilder
>
>
> but now the XHTML validator throws error saying that child element not
> supported !, and would show object reference error on the design view of
> the form
>
> am i missing anything ?
>
> thanks for your help again
>
>
>
>
>
>
>
>
> Keith Patrick wrote:
>
>> Check out the ParseChildrenAttribute class.  That affects how your
>> class is deserialized (parsed) by the asp engine such that you can
>> handle child elements differently than the default.  The default
>> behavior, I believe, is to attempt to add them as children of the
>> Controls collection, in which case, a) it would need to be a control,
>> and b) you'd need to qualify it with a tagname so that the engine
>> knows what type to deserialize the markup to.
>>
Author
4 Jan 2006 12:38 AM
Ashish
never mind i found out what the problem was :)


Ashish wrote:
Show quoteHide quote
> Thanks Keith,
>
> i found an example of a control at by using ControlBuilder class on
> http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx#builder
>
>
> I did exactly as mentioned in the sample by defining three classes, one
> for the main control, one for the child control, and one for the
> ControlBuilder, and then by decorating the main control class with the
> derived ControlBuilder
>
>
> but now the XHTML validator throws error saying that child element not
> supported !, and would show object reference error on the design view of
> the form
>
> am i missing anything ?
>
> thanks for your help again
>
>
>
>
>
>
>
>
> Keith Patrick wrote:
>
>> Check out the ParseChildrenAttribute class.  That affects how your
>> class is deserialized (parsed) by the asp engine such that you can
>> handle child elements differently than the default.  The default
>> behavior, I believe, is to attempt to add them as children of the
>> Controls collection, in which case, a) it would need to be a control,
>> and b) you'd need to qualify it with a tagname so that the engine
>> knows what type to deserialize the markup to.
>>