I am trying to create a user control for a layered menu. I created a first level control that works. Repeating it with a repeater and creating your own MenuButton class. Each MenuButton object has children of the same type.
Question: How to create a MenuButton control inside a MenuButton.aspx file?
I am using a repeater like this
<%@ Control ClassName="MenuButton" Language="C#" AutoEventWireup="true" CodeBehind="MenuButton.ascx.cs" Inherits="MenuSolution._12.TEMPLATE.CONTROLTEMPLATES.MenuButton, MenuSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=284eb573cd58385d" %> <%@ Register TagPrefix="a" Namespace="MenuSolution._12.TEMPLATE.CONTROLTEMPLATES" Assembly="MenuSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=284eb573cd58385d" %> <li runat="server"> <% if (Children.Count == 0) { %> <a href="<%# Url %>"><%# Description %></a> <% } else { %> <a href="<%# Url %>" class="dropdown-toggle" data-toggle="dropdown"> <%# Description %><b class="caret"></b></a> <ul class="dropdown-menu multi-level"> <asp:Repeater ID="repDynamicRows" runat="server"> <ItemTemplate> <a:MenuButton runat="server" id="button" url='<%# DataBinder.Eval(Container.DataItem, "Url") %>' children='<%# DataBinder.Eval(Container.DataItem, "ChildItems") %>' description='<%# DataBinder.Eval(Container.DataItem, "Description") %>' /> </ItemTemplate> </asp:Repeater> </ul> <% } %> </li>
and this code does not put the MenuButton code inside the final HTML. I tried to register this control, for example:
<%@ Register TagPrefix="a" TagName="MenuButton" Src="~/_controltemplates/MenuButton.ascx" %>
But this leads to a circular link.
How can I do it?
Tomasz
source share