I am trying to make a user controls for multi-level menu. I have created first-level control which works. Its iterating with repeater and instantiating my own MenuButton class. Each MenuButton object has children of same type.
The question is: How to create MenuButton control inside MenuButton.aspx file?
I am using 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 place MenuButton code inside final HTML. I was trying to register this control like:
<%@ Register TagPrefix="a" TagName="MenuButton" Src="~/_controltemplates/MenuButton.ascx" %>
But this leads to circural reference.
How should i do that?