N
~~~ .NET Ed ~~~
I am having problems trying to get this part of the functionality working on
my control and I hope somebody has a clue about how to resolve it.
1. How the relevant tags appear on the ASPX page. The @Register stuff is
omitted.
The control is basically a composite who also has a list of items (Items
property), every item that is defined gets
a tag of its own within the tag of the control in the ASPX page:
<cc3:CtPageHeader id="CtPageHeader1" runat="server">
<cc3:CtPageHeaderItem LinkURL="~/this.aspx"
Text="This"></cc3:CtPageHeaderItem>
<cc3:CtPageHeaderItem LinkURL="~/that.aspx"
Text="That"></cc3:CtPageHeaderItem>
</cc3:CtPageHeader>
So far so good. I can drop the control on the design surface, I can select
the Items property which in turn pops up a window to enter the items
(collection editor). As a result the items get inserted in the form as shown
above. The items are within the control's tag (InnerDefaultProperty).
2. This is how the control class has been declared. Notice that it has a
collection to hold the items and a property to access this collection. So
far so good AFAIK.
[DesignerAttribute(typeof(CtPageHeaderDesigner), typeof(IDesigner)),
DefaultProperty("Items"),
ToolboxData("<{0}:CtPageHeader runat=server></{0}:CtPageHeader>")]
public class DocHeader : System.Web.UI.WebControls.WebControl,
INamingContainer
{
// This member contains all the items defined for the control,
private CtPageHeaderLinkItemCollection items = new
CtPageHeaderLinkItemCollection();
[Category("Misc"),
Bindable(true),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
Description("The collection of Links and SubLinks")]
public CtPageHeaderLinkItemCollection Items
{
get { return this.items; }
set { this.items = value; }
}
:
}
3. The items that can be added as well as edited with the collection editor
are handled by a class that was declared as shown below (irrelevant code
omitted). For the sake of clarity in this message I am omitting the property
and using public members instead.
public class CtPageHeaderLinkItem : System.Web.UI.Control
{
public string LinkURL;
public string Text;
:
}
Up to here ok. The whole things builds OK. It functions perfectly AS LONG AS
I DO NOT DEFINE ANY ITEMS. As soon as I define items (like the two shown in
point #1) I get the following message on the Designer window for this
particular control:
Error Creating Control - CtPageHeader1
Parser Error: Type 'CtPageHeader does not have a property named
'cc3:CtPageHeaderLinkItem'
When I run the demo page the same error is displayed (obviously) by means of
an exception...
I tried by changing the name of the tags in #1 to "Items" (cc3:Items) in
hopes that it would go away considering there was now a property with the
same name as the inner tags which corresponded to the collection. The
problem still persists,
So, how can I "link" these two things so that these inner properties get
properly mapped (by the parser) to the Items property which is of type
CtPageHeaderLinkItem? I am obviously missing some finer point,
Thanks,
Emilio
my control and I hope somebody has a clue about how to resolve it.
1. How the relevant tags appear on the ASPX page. The @Register stuff is
omitted.
The control is basically a composite who also has a list of items (Items
property), every item that is defined gets
a tag of its own within the tag of the control in the ASPX page:
<cc3:CtPageHeader id="CtPageHeader1" runat="server">
<cc3:CtPageHeaderItem LinkURL="~/this.aspx"
Text="This"></cc3:CtPageHeaderItem>
<cc3:CtPageHeaderItem LinkURL="~/that.aspx"
Text="That"></cc3:CtPageHeaderItem>
</cc3:CtPageHeader>
So far so good. I can drop the control on the design surface, I can select
the Items property which in turn pops up a window to enter the items
(collection editor). As a result the items get inserted in the form as shown
above. The items are within the control's tag (InnerDefaultProperty).
2. This is how the control class has been declared. Notice that it has a
collection to hold the items and a property to access this collection. So
far so good AFAIK.
[DesignerAttribute(typeof(CtPageHeaderDesigner), typeof(IDesigner)),
DefaultProperty("Items"),
ToolboxData("<{0}:CtPageHeader runat=server></{0}:CtPageHeader>")]
public class DocHeader : System.Web.UI.WebControls.WebControl,
INamingContainer
{
// This member contains all the items defined for the control,
private CtPageHeaderLinkItemCollection items = new
CtPageHeaderLinkItemCollection();
[Category("Misc"),
Bindable(true),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerDefaultProperty),
Description("The collection of Links and SubLinks")]
public CtPageHeaderLinkItemCollection Items
{
get { return this.items; }
set { this.items = value; }
}
:
}
3. The items that can be added as well as edited with the collection editor
are handled by a class that was declared as shown below (irrelevant code
omitted). For the sake of clarity in this message I am omitting the property
and using public members instead.
public class CtPageHeaderLinkItem : System.Web.UI.Control
{
public string LinkURL;
public string Text;
:
}
Up to here ok. The whole things builds OK. It functions perfectly AS LONG AS
I DO NOT DEFINE ANY ITEMS. As soon as I define items (like the two shown in
point #1) I get the following message on the Designer window for this
particular control:
Error Creating Control - CtPageHeader1
Parser Error: Type 'CtPageHeader does not have a property named
'cc3:CtPageHeaderLinkItem'
When I run the demo page the same error is displayed (obviously) by means of
an exception...
I tried by changing the name of the tags in #1 to "Items" (cc3:Items) in
hopes that it would go away considering there was now a property with the
same name as the inner tags which corresponded to the collection. The
problem still persists,
So, how can I "link" these two things so that these inner properties get
properly mapped (by the parser) to the Items property which is of type
CtPageHeaderLinkItem? I am obviously missing some finer point,
Thanks,
Emilio