
I am using the latest version of Telerik MVC with my ASP.NET MVC 3 application. I took what was in contents and put it into another directory under root -> Assets -> telerikaspnetmvc68803. I don't know where to specify that the path has changed because it is still looking for the controls under ~/Content/...
Do I need to add my stylesheets like this? Can I just add them like I would normally add them?
@(Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group
.Add("telerik.common.min.css")
.Add("telerik.webblue.min.css")
//.Combined(true)
.Compress(true)))
I normally just add it like this:
<link href=".. style goes here.." rel="stylesheet" type="text/css">
If I were to register my javascripts like this then it adds a reference to a jquery file. I don't want this reference to be added because I have a newer version that I want to use. How do I get it to use the newer version?
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.Add("telerik.common.min.js")
.Add("telerik.treeview.min.js")
.Compress(true)))
Please help :)
Brendan
10 Answers, 1 is accepted

Here is how I did it:
WebAssetDefaultSettings.ScriptFilesPath = @"~/Assets/Scripts";
WebAssetDefaultSettings.StyleSheetFilesPath = @"~/Assets/Sheets";
You need to set DefaultPath(), as described in the documentation:
http://www.telerik.com/help/aspnet-mvc/web-assets-working-with-javascript-web-assets.html#ChangeDefaultPath
Note that the setting must come before the Add() statements in the group.
The same page explains how to disable the automatic jQuery registration.
All the best,
Dimo
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

I have my own stylesheets and jQuery files in a different location than where my Telerik files are. When using StyleSheetRegistrar in my scenario, is this the best way to do it? This is how I did it:
@(Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Content/")
.Add("telerik.common.css")
.Add("telerik.webblue.min.css")
.DefaultPath("~/Assets/Stylesheets/")
.Add("hef.css")
.Compress(true)
)
)
Also when using ScriptRegistrar, is this how it must be done when I want to add my own JavaScript files to the Telerik files? Do I need to specify the Compress and JQuery properties twice?
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.jQuery(false)
)
@{Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/JavaScripts/jQuery/")
.Add("jquery-1.6.2.min.js")
.Compress(true)
)
.jQuery(false);
}
The correct way to achieve your goal is to use additional group(s), not define several paths for the same group. Please refer to the previously provided documentation page.
Regards,
Dimo
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

Ok thank I will do just that. I tried the following as what you suggested but it is not working. I have the latest jQuery file in its own location. So I am wanting to load this jQuery file first like:
@(Html.Telerik().ScriptRegistrar()
.Scripts(scripts => scripts
.AddGroup("JavaScriptAssetLocation", group => group
.Add("~/Assets/JavaScripts/jQuery/jquery-1.6.2.min.js")
.Compress(true)
)
)
.jQuery(false)
)
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.jQuery(false)
)
It gives an error after the first ScriptRegistrar. It is looking for telerik.common.js. Error:
Specified file does not exist: "~/Scripts/telerik.common.js".
Please help me construct this correctly. I even tried swapping around the 2 ScriptRegistrar but it seems like it needs jQuery to be loaded first.
Thanks.
As suggested by the error, you need to define the DefaultGroup path in the first ScriptRegistrar. Currently I don't see a reason to have two ScriptRegistrars.
Regards,
Dimo
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

Hi,
I don't think you are understanding what I am trying to do.
I have my jQuery file in a different directory as to what comes default with Visual Studio. The reason for this is because I have downloaded the latest version of jQuery jquery-1.6.2.min.js. I have my Telerik MVC content and scripts directories in a different directory. As to what I have seen the Telerik scripts needs the jQuery file to be loaded first. I have deleted the content and scripts directories that come by default with an ASP.NET MVC application.
Telerik scripts directory:
~/Assets/telerikaspnetmvc/2011.2.712/Scripts/
My jQuery directory:
~/Assets/JavaScripts/jQuery/
I changed the ScriptRegistrar (as to your recommendation) to that of below:
@(Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.Scripts(scripts => scripts
.AddGroup("JavaScriptAssetLocation", group => group
.DefaultPath("~/Assets/JavaScripts/jQuery/")
.Add("jquery-1.6.2.min.js")
.Compress(true)
)
)
.jQuery(false)
)
This gave me an error. I swapped the 2 around so that it can read jQuery first as such but it still seems to load the default Telerik JavaScript files first. This is the changed code:
@(Html.Telerik().ScriptRegistrar()
.Scripts(scripts => scripts
.AddGroup("JavaScriptAssetLocation", group => group
.DefaultPath("~/Assets/JavaScripts/jQuery/")
.Add("jquery-1.6.2.min.js")
.Compress(true)
)
)
.DefaultGroup(group => group
.DefaultPath("~/Assets/telerikaspnetmvc/2011.2.712/Scripts/")
.Compress(true)
)
.jQuery(false)
)
What am I doing wrong here? Please provide code samples as to how it must be done.
The correct configuration is:
@(Html.Telerik().ScriptRegistrar()
.Scripts(scr => scr.AddGroup("jq", group => group.Add("~/jquery-location/jquery-1.6.2.min.js")))
.DefaultGroup(group => group.DefaultPath("~/telerik-scripts-location/"))
.jQuery(false)
)
However, it turned out that the DefaultGroup scripts are always output first, so you should abandon this approach and register the jQuery script outside (and before) the ScriptRegistrar.
Greetings,
Dimo
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

Just another question. Do I need to specify Compress(true) per group or is once enough? And jQuery(false) needs to be specified where? Only after DefaultGroup? Or anywhere?
As seen in the ScriptRegistrar declaration, Compress(true) and Combined(true) are defined per group, so you should set them multiple times, if needed. Note that compression works only if combination is enabled.
Regards,
Dimo
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