我正在尝试在页面加载时在运行时构建juiceui菜单,但我没有运气。如果我在设计时构建菜单但需要在运行时构建它,它的工作正常。任何帮助将非常感激!这是我到目前为止的代码......
c#code:
private void BuildLoginMenu()
{
Juice.Menu jMenuContainer = new Juice.Menu();
Juice.MenuItem parentItem = new Juice.MenuItem();
parentItem.ID = "Parent1";
MenuTemplate p = new MenuTemplate("Parent");
parentItem.Content = p;
Juice.MenuItem childItem = new Juice.MenuItem();
childItem.ID = "Parent1";
MenuTemplate c = new MenuTemplate("Parent");
childItem.Content = c;
parentItem.Items.Add(childItem);
jMenuContainer.Items.Add(parentItem);
Placeholder1.Controls.Add(jMenuContainer);
}
}
这里是MenuTemplate类供参考:
public class MenuTemplate : ITemplate
{
private string _text;
public MenuTemplate(string text)
{
_text = text;
}
public void InstantiateIn(Control container)
{
LiteralControl l = new LiteralControl(_text);
container.Controls.Add(l);
}
}