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
Solved

Remove extra white space in asp.net dynamic  menu

Posted on 2013-12-26
3
1,233 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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