Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apply Bootstrap To ASPNet Menu Control
<!-- 1. wrap with a div to force generated menu float -->
<div style="float: left;">
<!--
2. set [SkipLinkText=""] to hide skip link anchor tag (which will cause element shift in chrome)
3. set [IncludeStyleBlock="false"] to disable asp.net menu control's styles, which would conflict with bootstrap styling
4. apply bootstrap css to menu
4.1 CssClass="nav navbar-fix-top"
4.2 StaticMenuStyle-CssClass="nav navbar-nav"
4.3 StaticSelectedStyle-CssClass="active"
4.4 DynamicMenuStyle-CssClass="dropdown-menu"
-->
<asp:Menu ID="Menu1"
runat="server"
Orientation="Horizontal"
StaticDisplayLevels="1"
DynamicPopOutImageUrl="../Img/arrow.png"
StaticEnableDefaultPopOutImage="False"
OnMenuItemClick="Menu1_MenuItemClick"
MaximumDynamicDisplayLevels="10"
EnableViewState="false"
CssClass="nav navbar-fix-top"
StaticMenuStyle-CssClass="nav navbar-nav"
StaticSelectedStyle-CssClass="active"
DynamicMenuStyle-CssClass="dropdown-menu"
IncludeStyleBlock="false"
SkipLinkText=""
RenderingMode="List">
</asp:Menu>
</div>
@FelCanelo
Copy link

FelCanelo commented Oct 25, 2015

Funciono la raja, vale gringo ql

@neonHorse
Copy link

neonHorse commented Apr 12, 2016

Thank you very much.
This helped me a great deal.

@jamsshhayd
Copy link

jamsshhayd commented Nov 6, 2017

Great!

@mkaimakamian
Copy link

mkaimakamian commented Aug 28, 2018

Excellent!

@aabhishrma
Copy link

aabhishrma commented Sep 10, 2018

Hi...I was looking for this as well. But this is not working for me. attaching menu . This is supposed to be multilevel menu but its showing only the 1st level, My menu is bound with sql server. Please help . In my case i want menu should open up to show sub menu in it
temp

not able to figure out whats wrong

@alhanashi
Copy link

alhanashi commented Sep 11, 2018

Excellent work dear,
I have one question, how can add class nav-item for li tag
in your example the StaticMenuStyle-CssClass="navbar-nav ml-auto" work for ul tag
and StaticMenuItemStyle-CssClass="nav-link" for a tag

I want to add class nav-item for li tag, could you help me in that??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment