Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable javascript generation by ASP.NET menu control

Tags:

asp.net

In my website I'm using the standard ASP.NET menu control. I already got so far as to write a custom control adapter to get rid of the rather tacky html output that is generated by the default control adapter.

One thing keeps buggering me though. Somehow ASP.NET is generating extra javascript that I don't want nor need for my menu controls, since I won't be using any of the dynamic features in the control. I replaced the control adapter, so it doesn't generate compatible HTML for that.

Anyone got an idea how I can prevent ASP.NET from generating the extra javascript for the menu control?

like image 323
Willem Meints Avatar asked Aug 06 '10 15:08

Willem Meints


1 Answers

This problem cropped up for me after upgraded to ASP.net 4.0 with the installation of vs 2010. The fix is to either force the menu to render as a table or to turn off the new CSS/javascript "features" that 4.0 adds. Settings the menu's RenderingMode attribute to "Table" fixed this problem for me even though I use a Menu Adapter to render the control with lists.

<asp:Menu ID="mnuStuff" runat="server" RenderingMode="Table">
    ...
</asp:Menu>

You can do this site wide setting controlRenderingCompatibilityVersion to 3.5 in the web.config:

<system.web> 
  <pages controlRenderingCompatibilityVersion="3.5"/> 
</system.web>

This will eliminate the rendering of inline javascript that asp injects in the base of the page.

like image 147
Tim Santeford Avatar answered Oct 06 '22 09:10

Tim Santeford