Menu Control Enhancement in ASP.NET 4.0

No.of Views791
Bookmarked0 times
Downloads 
Votes0
By  jalpesh   On  01 Jan 2011 07:01:15
Tag : ASP.NET , Menus
asp.net 3.5 asp.net menu control or old version was rendered through table. And we all know that it is very hard to have CSS applied to table. For a professional look of our website a CSS is must required thing.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

The asp.net 3.5 asp.net menu control or old version was rendered through table. And we all know that it is very hard to have CSS applied to table. For a professional look of our website a CSS is must required thing. But in asp.net 4.0 Menu control is table less it will loaded with UL and LI tags which is easier to manage through CSS. Another problem with table is it will create a large html which will increase your asp.net page KB and decrease your performance. While with UL and LI Tags its very easy very short. So You page KB Size will also be down.

Let’s take a simple example. Let’s Create a menu control in asp.net with four menu item like following.

<asp:Menu ID="myCustomMenu"  runat="server" >
 <Items>
     <asp:MenuItem Text="Menu1" Value="Menu1"></asp:MenuItem>
     <asp:MenuItem Text="Menu2" Value="Menu2"></asp:MenuItem>
     <asp:MenuItem Text="Menu3" Value="Menu3"></asp:MenuItem>
     <asp:MenuItem Text="Menu4" Value="Menu4"></asp:MenuItem>
 </Items>
</asp:Menu>

It will render menu in browser like following.

Image Loading

Now If we render this menu control with tables then HTML as you can see via view page source like following.

Image Loading

Now If in asp.net 4.0 It will be loaded with UL and LI tags and if you now see page source then it will look like following. Which will have must lesser HTML then it was earlier like following.

Image Loading

So isn’t that great performance enhancement?. It’s very cool. If you still like old way doing with tables then in asp.net 4.0 there is property called ‘RenderingMode’ is given. So you can set RenderingMode=Table then it will load menu control with table otherwise it will load menu control with UL and LI Tags.Happy programming.

 
Sign Up to vote for this article
 
About Author
 
jalpesh
Occupation-Software Engineer
Company-DotNetJaps
Member Type-Expert
Location-India
Joined date-08 May 2010
Home Page-http://www.dotnetjalps.com
Blog Page-http://www.dotnetjalps.com
I am jalpesh vadgamaa an Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having experience of five year in Microsoft .NET Technology.I am working as Project Leader in Mid Size company.My work area comprises of Enterprise Level projects using ASP.NET and other Microsoft .NET Technologies.Please feel free to contact me for any queries via posting comments on my blog I will try to reply as early as possible.
 
 
Other popularSectionarticles
Comments
By:ElaaberDate Of Posted:1/6/2011 5:45:33 AM
SQL db password
Hi How to add sql db with password to website project (C#). Thanks
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top