Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Web Composite Control

4 views
Skip to first unread message

Mirco Manta

unread,
May 13, 2012, 8:46:33 AM5/13/12
to
Hi,
I would like to create a my web custom control and add it to vs 2010,

I would get something like this in aspx page:

[code]
<cc2:ControlPanel ID="ControlPanel1" runat="server">
<cc2:Tab ID="Tab1" runat="server">
<Content>1</Content>
<Icon>2</Icon>
<Text>3</Text>
</cc2:Tab>
<cc2:Tab ID="Tab2" runat="server">
<Content>1</Content>
<Icon>2</Icon>
<Text>3</Text>
</cc2:Tab>
<cc2:Tab ID="Tab3" runat="server">
<Content>1</Content>
<Icon>2</Icon>
<Text>3</Text>
</cc2:Tab>
// ecc..
</cc2:ControlPanel>
[/code]

But I get the following errors:

La proprietà 'Tab' non prevede una proprietà denominata 'ID'.
C:\Users\Mirco\Documents\My Web Sites\Vitrum\Default.aspx(57): Compilazione
(web): System.Collections.Generic.List`1[[ControlPanel.Tab, ControlPanel,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] può avere solo
elementi di tipo 'ControlPanel.Tab'. 'Content' è di tipo
'System.Web.UI.HtmlControls.HtmlGenericControl'.

C:\Users\Mirco\Documents\My Web Sites\Vitrum\Default.aspx(58): Compilazione
(web): System.Collections.Generic.List`1[[ControlPanel.Tab, ControlPanel,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] può avere solo
elementi di tipo 'ControlPanel.Tab'. 'Icon' è di tipo
'System.Web.UI.HtmlControls.HtmlGenericControl'.

C:\Users\Mirco\Documents\My Web Sites\Vitrum\Default.aspx(59): Compilazione
(web): System.Collections.Generic.List`1[[ControlPanel.Tab, ControlPanel,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] può avere solo
elementi di tipo 'ControlPanel.Tab'. 'Text' è di tipo
'System.Web.UI.HtmlControls.HtmlGenericControl'.

the complete code is:

[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;

namespace ControlPanel
{
[AspNetHostingPermission(SecurityAction.Demand, Level =
AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
[ToolboxData("<{0}:Tab runat=\"server\" ></{0}:Tab>")]
[Description("Elemento del menù")]
public class Tab : CompositeControl
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public PlaceHolder Icon { get; set; }

[PersistenceMode(PersistenceMode.InnerProperty)]
public PlaceHolder Text { get; set; }

[PersistenceMode(PersistenceMode.InnerProperty)]
public PlaceHolder Content { get; set; }
}

[ToolboxData("<{0}:ControlPanel runat=server></{0}:ControlPanel>")]
[AspNetHostingPermission(SecurityAction.Demand,Level =
AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,Level =
AspNetHostingPermissionLevel.Minimal)]
[ParseChildren(true, "Tab")]
[Description("Menù")]
public class ControlPanel : CompositeControl
{
private List<Tab> _Tabs;

public ControlPanel()
{
_Tabs = new List<Tab>();
}

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
writer.Write("Ci sono " + _Tabs.Count.ToString() + " elementi
nel menù");
}

[
Description("L'insieme degli elementi del menù"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
public List<Tab> Tab
{
get
{
return _Tabs;
}
}
}


}
[/code]

Moreover, removing the tag nested <tab> ... </ tab> i have no errors, but i
get always 0 entry as result.

Any suggestions?

0 new messages