-
-
Notifications
You must be signed in to change notification settings - Fork 64
Paths
Shannon Deminick edited this page Apr 27, 2015
·
4 revisions
CDF allows you to have pre-defined paths for your dependencies to reference. This is handy in case you ever change the location of many assets, or if you want to do some kind of theming.
You can pre-define paths during application startup by adding to the PathsCollection
ClientDependency.Core.PathsCollection.AddPath("JQuery", "~/Js/Jquery");
You can also define path aliases when you render the JS/CSS.
@Html.RenderJsHere(
new BasicPath("JQuery", "~/Js/Jquery"),
new BasicPath("ControlStyles", "~/Css/Controls"))
NOTE: You can add as many paths as you like to the RenderJsHere and RenderCssHere methods.
<CD:ClientDependencyLoader runat="server" id="Loader" >
<Paths>
<CD:ClientDependencyPath Name="ControlStyles" Path="~/Css/Controls" />
<CD:ClientDependencyPath Name="JQuery" Path="~/Js/Jquery" />
</Paths>
</CD:ClientDependencyLoader>
Its super easy to use path aliases, you just need to specify the alias to use when declaring your dependency
@{
Html.RequiresCss("Content.css", "ControlStyles")
.RequiresJs("JQuery", "jquery.js");
}
<CD:JsInclude runat="server" FilePath="jquery.js" PathNameAlias="JQuery" />
<CD:CssInclude runat="server" FilePath="Content.css" PathNameAlias="ControlStyles" />