Я хочу создать серверный элемент управления следующим образом:
<%@ Register Assembly="MdsAccordionMenu" Namespace="MdsAccordionMenu" TagPrefix="cc1" %>
<cc1:MdsAccordionMenu ID="MdsAccordionMenu1" runat="server">
<MdsAccordionMenuItem Title="Some Title">
<MdsAccordionMenuItem Text="some text" Link="http://" IconUrl="image.png" />
<MdsAccordionMenuItem Text="some text" Link="http://" IconUrl="image.png" />
<MdsAccordionMenuItem Text="some text" Link="http://" IconUrl="image.png" />
<MdsAccordionMenuItem Text="some text" Link="http://" IconUrl="image.png" />
</MdsAccordionMenuItem>
</cc1:MdsAccordionMenu>
Я написал следующий код на C #, но он не работает:
MdsAccordionMenu.cs:
namespace MdsAccordionMenu
{
[ToolboxData("<{0}:MdsAccordionMenu runat=server></{0}:MdsAccordionMenu>")]
[ParseChildren(true, "MdsAccordionMenuItems")]
[DefaultProperty("MdsAccordionMenuItems")]
[Serializable]
public class MdsAccordionMenu : WebControl
{
[Description("سرعت نمایش انیمیشن")]
[DefaultValue(500)]
public int AnimationSpeed { get; set; }
[Browsable(false), PersistenceMode(PersistenceMode.InnerProperty)]
public List<MdsAccordionMenuItem> MdsAccordionMenuItems { get; set; }
}
}
MdsAccordionMenuItem.cs:
namespace MdsAccordionMenu
{
//[TypeConverter(typeof(ExpandableObjectConverter))]
[ParseChildren(true, "MdsAccordionItems")]
[DefaultProperty("Title")]
[Serializable]
public class MdsAccordionMenuItem
{
[Description("تیتر منو")]
[DefaultValue("Title")]
[NotifyParentProperty(true)]
public string Title { get; set; }
[Browsable(false), PersistenceMode(PersistenceMode.InnerProperty)]
[NotifyParentProperty(true)]
public List<MdsAccordionItem> MdsAccordionItems { get; set; }
}
}
MdsAccordionItem .cs:
namespace MdsAccordionMenu
{
[Serializable]
public class MdsAccordionItem : INamingContainer
{
[NotifyParentProperty(true)]
[Description("متن")]
public string Text { get; set; }
[NotifyParentProperty(true)]
[Description("آدرس لینک منو")]
public string Link { get; set; }
[NotifyParentProperty(true)]
[Description("آدرس آیکون")]
public string ImageUrl { get; set; }
}
}
Как я могу это сделать?