This is a migrated thread and some comments may be shown as answers.

Radmenu bottom page javascript

6 Answers 106 Views
Menu
This is a migrated thread and some comments may be shown as answers.
porlandi
Top achievements
Rank 1
porlandi asked on 03 Apr 2010, 07:41 PM
Hi,
Is there a way to remove the javascript code from the page's bottom since I don't need it?
Thanks

<script type="text/javascript">
//<![CDATA[
Sys.Application.initialize();
Sys.Application.add_init(function() {
$create(Telerik.Web.UI.RadMenu, 
{"_childListElementCssClass":null,"clientStateFieldID":"dnn_rm_RadMenu1_ClientState","collapseAnimation":"{\"duration\":450}","expandAnimation":"{\"duration\":450}","itemData":[{"groupSettings":{"flow":0,"expandDirection":0,"offsetX":0,"offsetY":0},"navigateUrl":"http://www.domainname.com/"},{"groupSettings":{"flow":0,"expandDirection":0,"offsetX":0,"offsetY":0},
..........]}, null, null, $get("dnn_rm_RadMenu1")); }); //]]></script>

6 Answers, 1 is accepted

Sort by
0
Dino
Top achievements
Rank 1
answered on 16 Apr 2010, 12:13 AM
Hi,

I too would like to remove this!

It's a LOT of code that gets generated there, and for SEO reasons, we have to be "economic" with our HTML code, otherwise we will get penalised...
0
porlandi
Top achievements
Rank 1
answered on 18 Apr 2010, 11:00 AM
Yep, that is the exact same reason I was thinking of. It would be nice to have a control's property that would disable this code insertion.
Thanks
0
Veselin Vasilev
Telerik team
answered on 19 Apr 2010, 12:55 PM
Hello porlandi,

ASP.NET renders the $create statements for every ajax server control and this cannot be avoided.
You can try with the MS Ajax Toolkit - you will encounter the same $create javascript on the page.

Regards,
Veskoni
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dino
Top achievements
Rank 1
answered on 19 Apr 2010, 01:58 PM
Hi Veskoni,

Thanks for clarifying that. I thought it might be for some such reason, and that's a shame. However, I still feel it's overkill in terms of code generated for a menu.

For example, I've created similar functionality before whereby the HTML LI items are parsed by Javascript after the onload event, and javascript events attached to each item to carry out the right functionality. If the RadMenu was treated similarly, then you wouldn't need any of the Javascript at the bottom of the page (which repeats a lof of the stuff that's already in the HTML UL markup for the Menu!). You would simply have a Javascript object in a separate JS file that will actually be cached. Hence it'll also be faster to load!

The other benefit is that search engines (and other entities) can cache the page, whereas with your approach it's a problem because the references to WebResource.axd can't be cached. Is this not why this would generated "Padding is invalid and cannot be removed." errors?

Anyway, considering that the menu is likely to appear on EVERY page on a site, it's a shame that the code generated to drive it is not a lot "neater", I may have to resort to creating my own Javascript object for this...
0
T. Tsonev
Telerik team
answered on 20 Apr 2010, 01:49 PM
Hi Dino,

The RadMenu and other controls from the ASP.NET AJAX suite rely on having client-side objects for each control and item on the client to deliver rich client-side functionality. The items must be serialized as JSON or loaded from a Web Service, but they must be there and there's no way to turn this off. We've tried to optimize this as much as we could and values that are rendered in the HTML are not serialized.

If you want full control over the markup and lightweight client-side objects you might consider ASP.NET MVC and the Telerik Extensions for ASP.NET MVC.

The "Padding is invalid and cannot be removed" error is occurring in the WebResource.axd handler which is part of ASP.NET and is not specific to Telerik controls. You can avoid this problem by setting a permanent machine key as described in this blog post.

Another option is to load the control scripts and skins from the Telerik CDN. In this case the scripts and skins are served directly and not through a handler. It's will also reduce latencies for customers.

I hope this helps.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
porlandi
Top achievements
Rank 1
answered on 23 Apr 2010, 08:09 AM
Hi,
Is it possible by using the Telerik MVC Menu to get the CSS classes for the first/last item in the menu and the CSS classes for the selected items in a easy way? Is there any web resources on that topic?

Thanks
Tags
Menu
Asked by
porlandi
Top achievements
Rank 1
Answers by
Dino
Top achievements
Rank 1
porlandi
Top achievements
Rank 1
Veselin Vasilev
Telerik team
T. Tsonev
Telerik team
Share this question
or