Menu inside noscript tag

2 posts, 0 answers
  1. Kam
    Kam avatar
    1 posts
    Member since:
    Sep 2011

    Posted 03 Oct 2013 Link to this post

    Hi,

    I have implemented a two level radmenu on our website and trying to render a secondary menu in case javascript is disabled on client's browser. I want this second menu to appear under the main menu only if javascript is disabled on the browser, so I am rendering this second radmenu inside <noscript> tag. It works fine as expected when javscript is disabled, and also works fine (menu doesn't appear) if javasript is enabled.
    However, I get a javascript error (obviously when it's enabled) :
    Error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
    Parameter name: element
    By looking at the Call Stack of the browser's developers tool, I think it is due to the following script that gets rendered automatically by telerik on the page (I have trimmed down the syntax)

    Sys.Application.add_init(function() {
        $create(Telerik.Web.UI.RadMenu, {"_childListElementCssClass":null,"_enableItemImagesPreloading":true,"_flow":0,"_skin...;
    });

    It is definitely something to do with radmenu inside <noscript> tag, as if I render it without this tag, and with javascript enabled on browser, everything works fine.

    I am using IE 8 with compatibility mode turned on.

    Thanks in advance

    Kam
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 04 Oct 2013 Link to this post

    Hi,

    In order to use the RadMenu in scenarios when the javascript is disabled, there are two properties which should be set to false. The first one is  RegisterWithScriptManager and the second one is EnableEmbeddedScripts. When these properties are set the framework won't try to execute the $create statement for the menu inside the "noscript" tag. I just want to mention that our controls rely heavily on javascript so you won't be able to interact with the control if the java-script on the page is disabled). Here is a sample markup with the aforementioned properties set to false for the "noscript" menu:
    <form id="form1" runat="server">
           <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
           <div>
               <telerik:RadMenu ID="RadMenu1" runat="server">
                   <Items>
                       <telerik:RadMenuItem Text="Item1">
                           <Items>
                               <telerik:RadMenuItem Text="Item1"></telerik:RadMenuItem>
                               <telerik:RadMenuItem Text="Item2"></telerik:RadMenuItem>
                               <telerik:RadMenuItem Text="Item3"></telerik:RadMenuItem>
                           </Items>
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem Text="Item2"></telerik:RadMenuItem>
                       <telerik:RadMenuItem Text="Item3"></telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenu>
               <noscript>
                   <telerik:RadMenu ID="RadMenu2" runat="server" RegisterWithScriptManager="false" EnableEmbeddedScripts="false">
                       <Items>
                           <telerik:RadMenuItem Text="Item2">
                               <Items>
                                   <telerik:RadMenuItem Text="Item1"></telerik:RadMenuItem>
                                   <telerik:RadMenuItem Text="Item2"></telerik:RadMenuItem>
                                   <telerik:RadMenuItem Text="Item3"></telerik:RadMenuItem>
                               </Items>
                           </telerik:RadMenuItem>
                           <telerik:RadMenuItem Text="Item2"></telerik:RadMenuItem>
                           <telerik:RadMenuItem Text="Item3"></telerik:RadMenuItem>
                       </Items>
                   </telerik:RadMenu>
               </noscript>
           </div>
       </form>


    Regards,
    Dimitar Terziev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top