I'm developing an ASP.NET 4 web application. When I put a Menu control into the web form, the menu causes the following code to generate just before the closing </form>
tag:
<script type='text/javascript'>
new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500,
orientation: 'horizontal', tabIndex: 0, disabled: false });
As long as I don't use URL Rewriting, the page compiles and loads properly. When I try to use URL Rewriting on the website, Visual Studio starts to throw "Sys is undefined" JavaScript exception.
However, this does not happen always. Most frequently it happens when I change somenting positioning-related in the CSS file, but sometimes the exceptions seems just arbitrary.
How can this be fixed?
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>
If you do not need to take advantage of asp 4.0 new css enhancements you can disable the injection of that new Sys.WebForms.Menu
altogether with the following setting 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With