Solved

Remove extra white space in asp.net dynamic  menu

Posted on 2013-12-26
3
1,244 Views
Last Modified: 2013-12-31
Dynamic menu appears correctly from a file named MenuTest.aspx. Dynamic menu items are separated by white spaced when the menu is rendered from Site.Master.

Rendered correctly:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MenuTest.aspx.cs"
     Inherits="StockProMax.MenuTest" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Main Menu Page </title>
</head>
<body>
    <form id="form1" runat="server">
        Main Menu Page
        <br />
    <div>
   
        <asp:Menu ID="Menu1" runat="server"
            Orientation="Horizontal"
            CssClass="Menu"
            RenderingMode="Table"
            DynamicMenuItemStyle-ItemSpacing="2px"
            DynamicMenuStyle-BackColor="White"
            DynamicHorizontalOffset="2"
            DynamicMenuItemStyle-BackColor="Yellow"
            DynamicMenuItemStyle-VerticalPadding="1px"
            DynamicMenuStyle-BorderStyle="Solid"
            DynamicMenuStyle-HorizontalPadding="1px"
            DynamicMenuStyle-VerticalPadding="1px"
            DynamicSelectedStyle-BackColor="Lime"
            DynamicVerticalOffset="1"  
            IncludeStyleBlock="False"
            MaximumDynamicDisplayLevels="2"
            DisappearAfter="-1"
            Height="16px" Width="100px">
           
            <Items>
            <asp:MenuItem NavigateUrl="#" Text="Basics" Value="mnuBasics">
                <asp:MenuItem
                    NavigateUrl="Default.aspx" Text="Home" Value="mnuHome" >
                </asp:MenuItem>
                   
                <asp:MenuItem
                    NavigateUrl="ContactUs.aspx" Text="Contact Us" Value="mnuContactUs">
                </asp:MenuItem>

            </asp:MenuItem>
                   
            <asp:MenuItem NavigateUrl="#" Text="Features" Value="mnuFeatures">
                <asp:MenuItem
                    NavigateUrl="BestPicks.aspx" Text="Best Picks(Registered Users)" Value="mnuBestPicks">
                </asp:MenuItem>
                   
                <asp:MenuItem
                    NavigateUrl="FinanceTermsDefn.aspx" Text="Finance Terms" Value="mnuFinanceTerms">
                </asp:MenuItem>
 
            </asp:MenuItem>
               
            <asp:MenuItem NavigateUrl="#" Text="Registration" Value="mnuRegistration">
                   
                <asp:MenuItem
                    NavigateUrl="RenewSubscription.aspx" Text="Renew Subscription" Value="mnuRenew">
                </asp:MenuItem>

                <asp:MenuItem
                    NavigateUrl="RegisterFree.aspx" Text="Free Trial" Value="mnuFreeTrial">
                </asp:MenuItem>
                   
                <asp:MenuItem
                    NavigateUrl="ReplacePassword.aspx" Text="Replace Password" Value="mnuReplacePassword">
                </asp:MenuItem>

                <asp:MenuItem
                    NavigateUrl="ChangePassword.aspx" Text="Change Password" Value="mnuChangePassword">
                </asp:MenuItem>
            </asp:MenuItem>
               
            <asp:MenuItem NavigateUrl="#" Text="Site Usage Help" Value="mnuSiteHelp">
                <asp:MenuItem
                    NavigateUrl="ChangePasswordInstructions.aspx" Text="Password Change Help" Value="mnuChangePasswordHelp">
                </asp:MenuItem>
            </asp:MenuItem>

            <asp:MenuItem NavigateUrl="#" Text="Admin Only" Value="mnuAdminOnly">
                <asp:MenuItem
                    NavigateUrl="Admin/AdminMenu.aspx" Text="Admin Menu" Value="mnuAdminMenu">
                </asp:MenuItem>
                   
            </asp:MenuItem>
                 
            </Items>
       
       </asp:Menu>

    </div>
    </form>
</body>
</html>

Site.Master Renders Extra White Space:

 <header>
        <div class="content-wrapper">
            <div class="float-left">
                <p class="site-title">
                    <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/StockProLogo.jpg" />
                </p>
            </div>
           
            <div>  
                <asp:Menu ID="Menu1" runat="server"
                    Orientation="Horizontal"
                    CssClass="Menu"
                    RenderingMode="Table"
                    DynamicMenuItemStyle-ItemSpacing="2px"
                    DynamicMenuStyle-BackColor="White"
                    DynamicHorizontalOffset="2"
                    DynamicMenuItemStyle-BackColor="Yellow"
                    DynamicMenuItemStyle-VerticalPadding="1px"
                    DynamicMenuStyle-BorderStyle="Solid"
                    DynamicMenuStyle-HorizontalPadding="1px"
                    DynamicMenuStyle-VerticalPadding="1px"
                    DynamicSelectedStyle-BackColor="Lime"
                    DynamicVerticalOffset="0"  
                    IncludeStyleBlock="False"
                    MaximumDynamicDisplayLevels="2"
                    DisappearAfter="-1"
                    Height="16px" Width="100px"
                    class="auto-style1" style="width: auto; height: 24px;
                    font-family: Arial, Helvetica, sans-serif;
                    font-size: 14px; font-weight: bold; font-style: normal;
                    font-variant: normal; color: #0000FF; background-color: #FFFF00;
                    text-align: center;">
               
                        <Items>
                            <asp:MenuItem NavigateUrl="#" Text="Basics" Value="mnuBasics">
                                <asp:MenuItem
                                    NavigateUrl="Default.aspx" Text="Home" Value="mnuHome" >
                                </asp:MenuItem>
                   
                                <asp:MenuItem
                                    NavigateUrl="ContactUs.aspx" Text="Contact Us" Value="mnuContactUs">
                                </asp:MenuItem>

                            </asp:MenuItem>
                   
                            <asp:MenuItem NavigateUrl="#" Text="Features" Value="mnuFeatures">
                                <asp:MenuItem
                                    NavigateUrl="BestPicks.aspx" Text="Best Picks(Registered Users)" Value="mnuBestPicks">
                                </asp:MenuItem>
                   
                                <asp:MenuItem
                                    NavigateUrl="FinanceTermsDefn.aspx" Text="Finance Terms" Value="mnuFinanceTerms">
                                </asp:MenuItem>
 
                            </asp:MenuItem>
               
                           <asp:MenuItem NavigateUrl="#" Text="Registration" Value="mnuRegistration">
                   
                                <asp:MenuItem
                                    NavigateUrl="RenewSubscription.aspx" Text="Renew Subscription" Value="mnuRenew">
                                </asp:MenuItem>

                                <asp:MenuItem
                                    NavigateUrl="RegisterFree.aspx" Text="Free Trial" Value="mnuFreeTrial">
                                </asp:MenuItem>
                   
                                <asp:MenuItem
                                    NavigateUrl="ReplacePassword.aspx" Text="Replace Password" Value="mnuReplacePassword">
                                </asp:MenuItem>

                                <asp:MenuItem
                                    NavigateUrl="ChangePassword.aspx" Text="Change Password" Value="mnuChangePassword">
                                </asp:MenuItem>
                            </asp:MenuItem>
               
                            <asp:MenuItem NavigateUrl="#" Text="Site Usage Help" Value="mnuSiteHelp">
                                <asp:MenuItem
                                    NavigateUrl="ChangePasswordInstructions.aspx" Text="Password Change Help" Value="mnuChangePasswordHelp">
                                </asp:MenuItem>
                            </asp:MenuItem>

                    <asp:MenuItem NavigateUrl="#" Text="Admin Only" Value="mnuAdminOnly">
                        <asp:MenuItem
                        NavigateUrl="Admin/AdminMenu.aspx" Text="Admin Menu" Value="mnuAdminMenu">
                        </asp:MenuItem>
              </asp:MenuItem>
             
             </Items>
         </asp:Menu>
        </div>

I cannot find any difference in the code.

Thanks,
MainMenu.jpg
MainMenuCorrect.jpg
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39740102
What if you comment out this line, or change the height:
"class="auto-style1" style="width: auto; height: 24px; "
0
 

Accepted Solution

by:
Dovberman earned 0 total points
ID: 39740165
I changed the rendering mode to List.

RenderingMode="List"

Now I need to separate the static items and increase the menu width.
Fix-item-seperation.jpg
0
 

Author Closing Comment

by:Dovberman
ID: 39747899
This was the only change that worked.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Upgrading my SSIS package in VS 2012 6 88
Groupbox Control ? 2 29
Regarding swagger API 1 37
VB.net Filesystem watcher not working 5 37
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question