L
LucaP
Hi. I'm developing a sample custom web control that have a collection
property.
Here is some code:
[
ToolboxData("<{0}:MyWebControl runat=server></{0}:MyWebControl>"),
Designer(typeof(MyControlDesigner)),
ControlBuilder(typeof(MyControlBuilder)),
ParseChildren(false), PersistChildren(false)]
public class MyWebControl
{ ...
private ItemCollection items = new ItemCollection();
[Bindable(true),
Description("Collection of items"), NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ItemCollection Items
{
get
{
return items;
}
}
....}
The following html code is generated by VS.NET:
<html>
....
<MyCC:MyWebControl id="MyWebControl1" runat="server">
<Items>
<cc:Item ID="item1"></cc:Item>
<cc:Item ID="item2"></cc:Item>
<cc:Item ID="item3"></cc:Item>
</Items>
</MyCC:MyWebControl>
....
</html>
It's all ok at runtime. The html is ok too.
My problem is that at designtime the (DataBindings) property of the Item
controls is not available. If i try to click on the "..." i receive a
NullReferenceException! Why?
I have the same exception with every type of collection...
Is there a way to solve this problem?!
Thanx a lot.
Bye.
property.
Here is some code:
[
ToolboxData("<{0}:MyWebControl runat=server></{0}:MyWebControl>"),
Designer(typeof(MyControlDesigner)),
ControlBuilder(typeof(MyControlBuilder)),
ParseChildren(false), PersistChildren(false)]
public class MyWebControl
{ ...
private ItemCollection items = new ItemCollection();
[Bindable(true),
Description("Collection of items"), NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ItemCollection Items
{
get
{
return items;
}
}
....}
The following html code is generated by VS.NET:
<html>
....
<MyCC:MyWebControl id="MyWebControl1" runat="server">
<Items>
<cc:Item ID="item1"></cc:Item>
<cc:Item ID="item2"></cc:Item>
<cc:Item ID="item3"></cc:Item>
</Items>
</MyCC:MyWebControl>
....
</html>
It's all ok at runtime. The html is ok too.
My problem is that at designtime the (DataBindings) property of the Item
controls is not available. If i try to click on the "..." i receive a
NullReferenceException! Why?
I have the same exception with every type of collection...
Is there a way to solve this problem?!
Thanx a lot.
Bye.