About
Pricing
Community
Teams
Start Free Trial
Log in
Dovberman
asked on
4/16/2015
How to limit the width of an asp.net menu
My menu stretches across the entire page.
How can I set the width properties. ?
See images:
Thanks,
ASP.NET
HTML
7
1
Last Comment
Dovberman
8/22/2022 - Mon
Dovberman
4/16/2015
ASKER
This is the current code:
<asp:Menu ID="Menu2" runat="server"
Width="100px"
Orientation ="Horizontal"
CssClass ="MYMenuClass"
BackColor= "Aqua"
RenderingMode="Table"
DynamicMenuItemStyle-ItemS
pacing="2p
x"
DynamicMenuStyle-BackColor
="White"
DynamicHorizontalOffset="8
"
DynamicMenuItemStyle-BackC
olor="Yell
ow"
DynamicMenuItemStyle-Verti
calPadding
="1px"
DynamicMenuStyle-BorderSty
le="Solid"
DynamicMenuStyle-Horizonta
lPadding="
1px"
DynamicMenuStyle-VerticalP
adding="1p
x"
DynamicSelectedStyle-BackC
olor="Lime
"
DynamicVerticalOffset="1"
IncludeStyleBlock="False"
MaximumDynamicDisplayLevel
s="3"
DisappearAfter="-1"
Height="16px"
StaticMenuItemStyle-ItemSp
acing="8px
"
Font-Bold="True"
Font-Size="14pt"
ForeColor="Black"
StaticMenuItemStyle-Border
Style ="Solid"
StaticMenuItemStyle-Border
Width ="1px" Font-Names="Calibri"
StaticMenuItemStyle-Horizo
ntalPaddin
g="8px"
StaticHoverStyle-BackColor
="White"
DynamicHoverStyle-BackColo
r ="White"
StaticHorizontalOffset="1"
StaticMenuStyle-Width="10%
" StaticMenuItemStyle-Width=
"12px">
<Items>
<asp:MenuItem NavigateUrl="#" Text="Basics" Value="mnuBasics">
<asp:MenuItem
NavigateUrl="Default.aspx"
Text="Home" Value="mnuHome" >
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="ContactUs.asp
x" Text="Contact Us" Value="mnuContactUs">
</asp:MenuItem>
</asp:MenuItem>
Lokesh B R
4/16/2015
Hi,
Its working fine.
can you post the full code.
Capture.PNG
Dovberman
4/16/2015
ASKER
It worked when I created the menu in a simple web page.
The same code did not work in a site.master page.
<asp:ContentPlaceHolder runat="server" ID="HeadContent" />
<style type="text/css">
.auto-style1 {
width: 600px;
}
</style>
<style type="text/css">
.MYMenuClass {
color: Green;
background-color: #00FFFF;
}
.MYMenuClass ul {
background: #00FFFF;
border: 1px solid #648ABD;
}
.MYMenuClass ul li {
background: #00FFFF none no-repeat;
text-align: center; /* set width if needed.*/
width: 200px;
border: 1px solid #648ABD;
}
.MYMenuClass ul li a {
color: black;
padding: 4px 2px 4px;
padding-left: 8px !important;
border: 1px solid #648ABD;
border-bottom: 0;
}
.MYMenuClass ul li a:hover {
background-image: none;
}
.MYMenuClass ul li a:hover {
color: White;
}
</style>
</head>
</asp:ScriptManager>
<asp:Menu ID="Menu2" runat="server"
Orientation ="Horizontal"
CssClass ="MYMenuClass"
BackColor= "Aqua"
RenderingMode="Table"
DynamicMenuItemStyle-ItemS
pacing="2p
x"
DynamicMenuStyle-BackColor
="White"
DynamicHorizontalOffset="8
"
DynamicMenuItemStyle-BackC
olor="Yell
ow"
DynamicMenuItemStyle-Verti
calPadding
="1px"
DynamicMenuStyle-BorderSty
le="Solid"
DynamicMenuStyle-Horizonta
lPadding="
1px"
DynamicMenuStyle-VerticalP
adding="1p
x"
DynamicSelectedStyle-BackC
olor="Lime
"
DynamicVerticalOffset="1"
IncludeStyleBlock="False"
MaximumDynamicDisplayLevel
s="2"
DisappearAfter="-1"
Height="16px" Width="100px"
StaticMenuItemStyle-ItemSp
acing="8px
"
Font-Bold="True"
Font-Size="14pt"
ForeColor="Black"
StaticMenuItemStyle-Border
Style ="Solid"
StaticMenuItemStyle-Border
Width ="1px" Font-Names="Calibri"
StaticMenuItemStyle-Horizo
ntalPaddin
g="8px"
StaticHoverStyle-BackColor
="White"
DynamicHoverStyle-BackColo
r ="White" >
<DynamicHoverStyle BackColor="White"></Dynami
cHoverStyl
e>
<DynamicMenuItemStyle ItemSpacing="2px" VerticalPadding="1px" BackColor="Yellow"></Dynam
icMenuItem
Style>
<DynamicMenuStyle HorizontalPadding="1px" VerticalPadding="1px" BackColor="White" BorderStyle="Solid"></Dyna
micMenuSty
le>
<DynamicSelectedStyle BackColor="Lime"></Dynamic
SelectedSt
yle>
<Items>
<asp:MenuItem NavigateUrl="#" Text="Basics" Value="mnuBasics">
<asp:MenuItem
NavigateUrl="Default.aspx"
Text="Home" Value="mnuHome" >
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="ContactUs.asp
x" Text="Contact Us" Value="mnuContactUs">
</asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="#" Text="Features" Value="mnuFeatures">
<asp:MenuItem
NavigateUrl="BestPicks.asp
x" Text="Best Picks(Registered Users)" Value="mnuBestPicks">
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="FinanceTermsD
efn.aspx" Text="Finance Terms" Value="mnuFinanceTerms">
</asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="#" Text="Registration" Value="mnuRegistration">
<asp:MenuItem
NavigateUrl="RenewSubscrip
tion.aspx"
Text="Renew Subscription" Value="mnuRenew">
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="RegisterFree.
aspx" Text="Free Trial" Value="mnuFreeTrial">
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="ReplacePasswo
rd.aspx" Text="Replace Password" Value="mnuReplacePassword"
>
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="ChangePasswor
d.aspx" Text="Change Password" Value="mnuChangePassword">
</asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="#" Text="Site Usage Help" Value="mnuSiteHelp">
<asp:MenuItem
NavigateUrl="ChangePasswor
dInstructi
ons.aspx" Text="Password Change Help" Value="mnuChangePasswordHe
lp">
</asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="#" Text="Admin Only" Value="mnuAdminOnly">
<asp:MenuItem
NavigateUrl="Admin/AdminMe
nu.aspx" Text="Admin Menu" Value="mnuAdminMenu">
</asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="White"></Static
HoverStyle
>
<StaticMenuItemStyle HorizontalPadding="8px" ItemSpacing="8px" BorderWidth="1px" BorderStyle="Solid" Width="12px"></StaticMenuI
temStyle>
<StaticMenuStyle HorizontalPadding="1px" VerticalPadding="1px" Height="12px" Width="5px" BackColor="Aqua" BorderColor="Black" BorderStyle="Solid" BorderWidth="3px" CssClass="MYMenuClass"></S
taticMenuS
tyle>
</asp:Menu>
-----
Rendering is different.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Lokesh B R
4/16/2015
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dovberman
4/16/2015
ASKER
I will investigate further. Perhaps another variable on my master page is interfering.
Will give you feedback in 4 hours. I have a dental appointment.
Thanks,
Dovberman
Dovberman
4/16/2015
ASKER
I found the code in site.master that was interfering. I simply commented out the line.
Everything works now.
Thanks,
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.Master.cs
"
Inherits="StockPickerMax.S
iteMaster"
%>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<title><%: Page.Title %>- My ASP.NET Application</title>
<%-- Find out if this is really needed. Prevents proper rendering of the menu.
<webopt:BundleReference runat="server" Path="~/Content/css" />
--%>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-widt
h" />
<asp:ContentPlaceHolder runat="server" ID="HeadContent" />
<style type="text/css">
.auto-style1 {
width: 600px;
}
</style>
<style type="text/css">
.MYMenuClass {
color: Green;
background-color: #00FFFF;
}
Dovberman
4/16/2015
ASKER
Excellent and timely support.
Thanks,
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
<asp:Menu ID="Menu2" runat="server"
Width="100px"
Orientation ="Horizontal"
CssClass ="MYMenuClass"
BackColor= "Aqua"
RenderingMode="Table"
DynamicMenuItemStyle-ItemS
DynamicMenuStyle-BackColor
DynamicHorizontalOffset="8
DynamicMenuItemStyle-BackC
DynamicMenuItemStyle-Verti
DynamicMenuStyle-BorderSty
DynamicMenuStyle-Horizonta
DynamicMenuStyle-VerticalP
DynamicSelectedStyle-BackC
DynamicVerticalOffset="1"
IncludeStyleBlock="False"
MaximumDynamicDisplayLevel
DisappearAfter="-1"
Height="16px"
StaticMenuItemStyle-ItemSp
Font-Bold="True"
Font-Size="14pt"
ForeColor="Black"
StaticMenuItemStyle-Border
StaticMenuItemStyle-Border
StaticMenuItemStyle-Horizo
StaticHoverStyle-BackColor
DynamicHoverStyle-BackColo
StaticHorizontalOffset="1"
<Items>
<asp:MenuItem NavigateUrl="#" Text="Basics" Value="mnuBasics">
<asp:MenuItem
NavigateUrl="Default.aspx"
</asp:MenuItem>
<asp:MenuItem
NavigateUrl="ContactUs.asp
</asp:MenuItem>
</asp:MenuItem>