Parsing Children and embeded custom controls

G

gozza

Hi,

I am developing couple of custom controls and I can't really figure out what
I need to do for one of them to be parsed appropriately.

This is what I want to achieve: in the aspx file, I would have the code:

<cc:ControlA attr1="val1">
<cc:ControlB attiba="valx" />
<cc:ControlB attiba="valy" />
<cc:ControlB attiba="valz">
<SomeTemplate>
<!-- some html sequence -->
</SomeTemplate>
</cc:ControlB>
</cc:ControlA>

The class ControlA has the attribute ParseChildren set to true:

[ParseChildren(true,"ACollectionProperty")]

The class ControlB has the attribute ParseChildren set to true as well:

[ParseChildren(true)]

Of course, I also have ITemplate property SomeTemplate for the ControlB.
Now if I change the ParseChildren attribute to false for the parent
ControlA, I expected that in a IParserAccessor.AddParsedSubObject override I
would get a number of ControlB objects. As it turns out, I only get one
Literal control for the whole lot. But if I actually put an ASP.NET button
inside ControlA, the button does get parsed, created and passed in.

Now I am not sure if it's a matter of implementing a custom ControlBuilder?
I did try using one of the existing ControlBuilders (it sais in the
documentation that by default, all controls are associated with a
ControlBuilder AND a UserControlControlBuilder?!), but no luck so far?!

Any help will be appreciated.

Thank you,
Gozza
 
G

gozza

Ok...

Although I sort of decided to keep ParseChildren set to true for ControlA
afterall, am I right to assume that I have to create my own ControlBuilder
and provide a GetChildControlType() implementation where I'll return the
ControlB type for the ControlB tag?

Thanks,
Gozza
 
J

Jiho Han

Could it be that your ControlB tags don't contain runat="server" attribute
set?

gozza said:
Ok...

Although I sort of decided to keep ParseChildren set to true for ControlA
afterall, am I right to assume that I have to create my own ControlBuilder
and provide a GetChildControlType() implementation where I'll return the
ControlB type for the ControlB tag?

Thanks,
Gozza



gozza said:
Hi,

I am developing couple of custom controls and I can't really figure out what
I need to do for one of them to be parsed appropriately.

This is what I want to achieve: in the aspx file, I would have the code:

<cc:ControlA attr1="val1">
<cc:ControlB attiba="valx" />
<cc:ControlB attiba="valy" />
<cc:ControlB attiba="valz">
<SomeTemplate>
<!-- some html sequence -->
</SomeTemplate>
</cc:ControlB>
</cc:ControlA>

The class ControlA has the attribute ParseChildren set to true:

[ParseChildren(true,"ACollectionProperty")]

The class ControlB has the attribute ParseChildren set to true as well:

[ParseChildren(true)]

Of course, I also have ITemplate property SomeTemplate for the ControlB.
Now if I change the ParseChildren attribute to false for the parent
ControlA, I expected that in a IParserAccessor.AddParsedSubObject
override
I
would get a number of ControlB objects. As it turns out, I only get one
Literal control for the whole lot. But if I actually put an ASP.NET button
inside ControlA, the button does get parsed, created and passed in.

Now I am not sure if it's a matter of implementing a custom ControlBuilder?
I did try using one of the existing ControlBuilders (it sais in the
documentation that by default, all controls are associated with a
ControlBuilder AND a UserControlControlBuilder?!), but no luck so far?!

Any help will be appreciated.

Thank you,
Gozza
 
G

gozza

Yeah, I found out that that would be one way of solving it.

I'm still to try and build my own custom builder, which I think is the way
to do it.

Thanks for the response Jiho!
Gozza


Jiho Han said:
Could it be that your ControlB tags don't contain runat="server" attribute
set?

gozza said:
Ok...

Although I sort of decided to keep ParseChildren set to true for ControlA
afterall, am I right to assume that I have to create my own ControlBuilder
and provide a GetChildControlType() implementation where I'll return the
ControlB type for the ControlB tag?

Thanks,
Gozza



gozza said:
Hi,

I am developing couple of custom controls and I can't really figure
out
what
I need to do for one of them to be parsed appropriately.

This is what I want to achieve: in the aspx file, I would have the code:

<cc:ControlA attr1="val1">
<cc:ControlB attiba="valx" />
<cc:ControlB attiba="valy" />
<cc:ControlB attiba="valz">
<SomeTemplate>
<!-- some html sequence -->
</SomeTemplate>
</cc:ControlB>
</cc:ControlA>

The class ControlA has the attribute ParseChildren set to true:

[ParseChildren(true,"ACollectionProperty")]

The class ControlB has the attribute ParseChildren set to true as well:

[ParseChildren(true)]

Of course, I also have ITemplate property SomeTemplate for the ControlB.
Now if I change the ParseChildren attribute to false for the parent
ControlA, I expected that in a IParserAccessor.AddParsedSubObject
override
I
would get a number of ControlB objects. As it turns out, I only get one
Literal control for the whole lot. But if I actually put an ASP.NET button
inside ControlA, the button does get parsed, created and passed in.

Now I am not sure if it's a matter of implementing a custom ControlBuilder?
I did try using one of the existing ControlBuilders (it sais in the
documentation that by default, all controls are associated with a
ControlBuilder AND a UserControlControlBuilder?!), but no luck so far?!

Any help will be appreciated.

Thank you,
Gozza
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top