【发布时间】:2012-02-28 09:54:07
【问题描述】:
我正在学习服务器控件开发并寻找适当的说明以通过源以声明方式设置数据。例如,下拉列表控件提供如下声明性数据
<asp:DropDownList id="dropdown" runat="server">
<asp:ListItem text="Project Initiation" value="1"></asp:ListItem>
<asp:ListItem text="Documentation" value="2"></asp:ListItem>
</asp:DropDownList>
类似地,我正在寻找以声明方式向我的简单菜单控件提供数据,该菜单控件显示由来自数据源的如下图像包围的图像(输出标记)
<a>
<img src="" />
</a>
请不要指向我的链接,至少任何人都可以这样做。我想清楚地解释提供此类功能需要做什么。 我希望我的最终来源如下所示
<asp:sidebar runat="server" id="sb">
<asp:sidebaritem navigateurl="" imageurl="" label=""></asp:sidebaritem>
</asp:sidebar>
侧边栏项目类在下面定义,我也有一个属性
类
public class SidebarItem
{
private string _navigateUrl;
public string NavigateUrl
{
get { return _navigateUrl; }
set { _navigateUrl = value; }
}
. . .
}
属性
[PersistenceMode(PersistenceMode.InnerProperty)]
[NotifyParentProperty(true)]
public ICollection<SidebarItem> Items
{
get { return _sidebarItems; }
set { _sidebarItems = value; }
}
【问题讨论】:
标签: c# asp.net menu custom-controls custom-server-controls