C
Chris Simeone
Hi,
Below I've listed six questions that I would greatly appreciate
answers to. Hopefully the following scenario will help readers
understand what I need to accomplish and will help with answering my
questions...
=================================================================
I've created a test custom control that is declared as follows...
=================================================================
<tc:TestCtrl id="tstCtrl" runat="server" >
<HeaderStyle BackColor="Orange" ForeColor="Black" />
<RowStyle BackColor="tan" ForeColor="Black" />
<FooterStyle BackColor="green" ForeColor="white" />
</tc:TestCtrl>
Each "property" (HeaderStyle, RowStyle, FooterStyle and others to
come) will be represented by a style object in my code-behind. There
will also be a collection of theses "Style" objects.
=================================================================
My Control builder class looks like this...
=================================================================
public class tstBuilder : ControlBuilder
{
public override Type GetChildControlType(string tagName, IDictionary
attribs)
{
switch(tagName.ToLower())
{
case "HeaderStyle":
case "RowStyle":
case "FooterStyle":
{
return typeof(tstCtrlStyle);
}
}
return base.GetChildControlType(tagName, attribs);
}
=================================================================
The AddParsedSubObject code looks like this...
=================================================================
protected override void AddParsedSubObject(object obj)
{
if (obj is CalendarStyle)
{
tstControl tc = obj as tstControl;
this.Styles.Add(tc);
}
else
base.AddParsedSubObject (obj);
}
}
=================================================================
In AddParsedSubObject() I need to know what tagName the control
builder just processed so I can set the name of the style object to
that tag name as shown in the psuedo code below...
=================================================================
if (obj is tstControl)
{
tstControl tc = obj as tstControl;
tc.Name = the tag name processed in AddParsedSubObject...
this.Styles.Add(tc);
}
=================================================================
Here are my questions...
=================================================================
1) How can I get to the tag name outside of GetChildControlType()?
2) What is the purpose of the "attrib" parameter in
GetChildControlType()?
3) Can I use the "attrib" parameter in GetChildControlType() somehow
to pass the tag name around?
4) Can someone please explain the attribute [
ControlBuilderAttribute(typeof(tstControl)) ] and it's relationship to
overriding the parser? I just don't get it.
5) What is the purpose of the "IParserAccessor" interface and will it
serve any purpose for me?
6) Finally how can I step into GetChildControlType() and
AddParsedSubObject() when debugging?
Thanks!
Chris S.
Below I've listed six questions that I would greatly appreciate
answers to. Hopefully the following scenario will help readers
understand what I need to accomplish and will help with answering my
questions...
=================================================================
I've created a test custom control that is declared as follows...
=================================================================
<tc:TestCtrl id="tstCtrl" runat="server" >
<HeaderStyle BackColor="Orange" ForeColor="Black" />
<RowStyle BackColor="tan" ForeColor="Black" />
<FooterStyle BackColor="green" ForeColor="white" />
</tc:TestCtrl>
Each "property" (HeaderStyle, RowStyle, FooterStyle and others to
come) will be represented by a style object in my code-behind. There
will also be a collection of theses "Style" objects.
=================================================================
My Control builder class looks like this...
=================================================================
public class tstBuilder : ControlBuilder
{
public override Type GetChildControlType(string tagName, IDictionary
attribs)
{
switch(tagName.ToLower())
{
case "HeaderStyle":
case "RowStyle":
case "FooterStyle":
{
return typeof(tstCtrlStyle);
}
}
return base.GetChildControlType(tagName, attribs);
}
=================================================================
The AddParsedSubObject code looks like this...
=================================================================
protected override void AddParsedSubObject(object obj)
{
if (obj is CalendarStyle)
{
tstControl tc = obj as tstControl;
this.Styles.Add(tc);
}
else
base.AddParsedSubObject (obj);
}
}
=================================================================
In AddParsedSubObject() I need to know what tagName the control
builder just processed so I can set the name of the style object to
that tag name as shown in the psuedo code below...
=================================================================
if (obj is tstControl)
{
tstControl tc = obj as tstControl;
tc.Name = the tag name processed in AddParsedSubObject...
this.Styles.Add(tc);
}
=================================================================
Here are my questions...
=================================================================
1) How can I get to the tag name outside of GetChildControlType()?
2) What is the purpose of the "attrib" parameter in
GetChildControlType()?
3) Can I use the "attrib" parameter in GetChildControlType() somehow
to pass the tag name around?
4) Can someone please explain the attribute [
ControlBuilderAttribute(typeof(tstControl)) ] and it's relationship to
overriding the parser? I just don't get it.
5) What is the purpose of the "IParserAccessor" interface and will it
serve any purpose for me?
6) Finally how can I step into GetChildControlType() and
AddParsedSubObject() when debugging?
Thanks!
Chris S.