I'm building an ASP.Net 4.5 menu programmatically in C#. The top menu items are formatted to my liking, but the formatting isn't being inherited by the child items. The formatting I'm most concerned with are two things: StaticEnableDefaultPopOutImage, which controls whether that little arrow shows up next to the MenuItem, and ItemSpacing. The former is set to false in the asp:Menu definition and works for the top menu items (i.e., no little arrow shows up), but fails to work for the child items (the little arrow does show up next to the child items). The latter is set to 75px, and the top menu items are nicely spaced apart. However, the child items and their child items are crammed next to each other. I'm not sure how to control this behavior. Finally, the menu is defined in a Master Page. Here's my menu code in Master:
<asp:Menu runat="server" CssClass="bgcell_top_nav" ID="menuMain" Orientation="Horizontal" RenderingMode="Table" StaticEnableDefaultPopOutImage="false" Width="100%" ItemWrap="false" Height="250" DynamicVerticalOffset="8" StaticDisplayLevels="1">
<StaticMenuItemStyle ItemSpacing="75px" />
</asp:Menu>
And this is my code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//top menu items
MenuItem ApplicationFunctionality = new MenuItem();
ApplicationFunctionality.Text = "Applications";
ApplicationFunctionality.SeparatorImageUrl = "~/images/menu-pipe.png";
this.menuMain.Items.Add(ApplicationFunctionality);
MenuItem DatabaseFunctionality = new MenuItem();
DatabaseFunctionality.Text = "Databases";
DatabaseFunctionality.SeparatorImageUrl = "~/images/menu-pipe.png";
this.menuMain.Items.Add(DatabaseFunctionality);
//sub menu items
MenuItem Application_Add = new MenuItem();
Application_Add.Text = "Add";
ApplicationFunctionality.ChildItems.Add(Application_Add);
MenuItem Application_Search = new MenuItem();
Application_Search.Text = "Search";
ApplicationFunctionality.ChildItems.Add(Application_Search);
MenuItem Application_Reports = new MenuItem();
Application_Reports.Text = "Reports";
ApplicationFunctionality.ChildItems.Add(Application_Reports);
MenuItem CreateInternalApplication = new MenuItem();
CreateInternalApplication.Text = "Internal";
CreateInternalApplication.NavigateUrl = "~/TemplateForms/ApplicationCreationTemplateForm.aspx";
Application_Add.ChildItems.Add(CreateInternalApplication);
MenuItem CreateExternalApplication = new MenuItem();
CreateExternalApplication.Text = "External";
Application_Add.ChildItems.Add(CreateExternalApplication);
}
}
And I'm attaching a picture of what this looks like so people can see what the issues are I'm talking about.
Any guidance as to how to format the child items is much appreciated.