我有一个生成一系列箭头按钮的用户控件。我希望每个按钮都显示一个自定义用户控件。我的自定义箭头按钮导航控件在呈现时如下所示:
完成后,单击按钮将在箭头下方显示用户控件。每个箭头按钮都需要绑定到包含特定于该按钮的独特功能的自定义用户控件。目前,我在用户控件上有一个简单的List<ArrowTab> Tabs { get; set; }
属性,并且在托管用户控件的页面的 page_load 中,我以编程方式添加了一些示例选项卡(如上所示),如下所示:
TabWizard1.Tabs = new List<ArrowTab>
{
new ArrowTab
{
Text = "Project Settings",
Selected = true
},
new ArrowTab { Text = "Groups" },
new ArrowTab { Text = "Products" },
new ArrowTab { Text = "Make Assignments" },
new ArrowTab { Text = "Review Assignments" },
new ArrowTab { Text = "Commitments" }
};
这适用于从后面的代码中添加按钮,但我真正想要的是在页面上的用户控件的标记中添加按钮,并将不同的自定义用户控件关联到该按钮。例如,我想做这样的事情:
<uc:TabWizard ID="TabWizard1" runat="server">
<items>
<arrowTab Text="Project Settings">
<uc:ProjectSettingsControl ID="projectSettings1" runat="server" />
</arrowTab>
<arrowTab Text="Groups">
<uc:GroupsControl ID="groups1" runat="server" />
</arrowTab>
<arrowTab Text="Products">
<uc:ProductsControl ID="products1" runat="server" />
</arrowTab>
<arrowTab Text="Make Assignments">
<uc:MakeAssignmentsControl ID="makeAssignments1" runat="server" />
</arrowTab>
<arrowTab Text="Review Assignments">
<uc:ReviewAssignmentsControl ID="reviewAssignments1" runat="server" />
</arrowTab>
<arrowTab Text="Commitments">
<uc:CommitmentsControl ID="commitments1" runat="server" />
</arrowTab>
</items>
</uc:TabWizard>
Telerik RadPanel 控件就是一个已经在做类似事情的例子。
<telerik:RadPanelItem Text="Mail" ImageUrl="Img/mail.gif" Expanded="True">
<Items>
<telerik:RadPanelItem ImageUrl="Img/mailPersonalFolders.gif" Text="Personal Folders" />
<telerik:RadPanelItem ImageUrl="Img/mailDeletedItems.gif" Text="Deleted Items" />
<telerik:RadPanelItem ImageUrl="Img/mailInbox.gif" Text="Inbox" />
<telerik:RadPanelItem ImageUrl="Img/mailFolder.gif" Text="My Mail" />
<telerik:RadPanelItem ImageUrl="Img/mailSent.gif" Text="Sent Items" />
<telerik:RadPanelItem ImageUrl="Img/mailOutbox.gif" Text="Outbox" />
<telerik:RadPanelItem ImageUrl="Img/mailSearch.gif" Text="Search Folders" />
</Items>
</telerik:RadPanelItem>
我不知道如何创建允许这种行为的用户控件。即使只是朝着正确的方向轻推也会是有益的。