ASP.NET ControlBuilder with ITemplate

J

Jonathan Gauthier

Hi,

Does anyone has already implemented an ASP.NET custom control with a
custom ControlBuilder and having this control supports one or many
ITemplate (s)?

I want to support any kind of children between my controls tag but I
don't want them to be parsed as children but the templates does. So I
have set the ParseChildren attribute to false, but now
I don't know how to make the parser loading the templates…


Here is an example:

<myControl id="myControlInstance" runat="server" Height="600px"
Width="600px">
<table>
<tr>
<td>
<MyTemplate>
<%# Container.DataItem.MyValue %>
</MyTemplate
</td>
</tr>
</table>
</myControl>

If ParseChildren is set to true then every tag those are not matching
a property of the control will make the parsing fails.

If ParseChildren is set to false, then I am not sure what the
GetChildControlType method of the ControlBuilder should return…

I tried this without any success:

public class MyControlBuilder : ControlBuilder
{
public override Type GetChildControlType(String tagName,
IDictionary attributes)
{
if(String.Compare(tagName, " MyTemplate ", true) == 0)
return typeof(TemplateBuilder);


return base.GetChildControlType(tagName, attributes);
}
}

Even if it would have work I don't know either what I would have to
return in the overridden AddParsedSubObject method of my control for a
template.
This custom parsing topic is definitively poorly documented. I could
not find any documentation about the TemplateBuilder class either



Any help will be much appreciated.

Thanks.
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top