Solved

Remove extra white space in asp.net dynamic  menu

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

3 Use Cases for Connected Systems

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

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.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now