Friday, December 31, 2010

ASP.NET 4.0- Menu control enhancement.

Till 3.5 menu control 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 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 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 with four menu item like following.

<asp:Menu ID="myCustomMenu"  runat="server" >
<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>
It will render menu in browser like following. menu control enhancement in vesion 4.0

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

Old menu in 3.5 with table.

Now If in 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.


So isn’t that great performance enhancement?.. It’s very cool. If you still like old way doing with tables then in 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.

That’s it..Stay tuned for more..Happy programming..

Technorati Tags: ,
Shout it


Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews