-
-
Notifications
You must be signed in to change notification settings - Fork 64
Forced Providers
In the config you will notice that there are a few differnet providers. CDF allows you to render certain dependencies with different providers. By default all dependencies will be rendered with the default providers configured.
There are 2 types of providers, one type is for MVC and the other is for Webforms. The MVC provider base class is BaseRenderer
, the Webforms provider base class is WebFormsFileRegistrationProvider
. Both provider types share the same functionality: They are the classes that render the script
and link
tag output.
You can also create your own providers if you have a specific, currently un-supported way of rendering scripts or styles.
In some cases you might want your script
or link
tags to be rendered differently or in different locations on the page. In either of these cases you can force certain dependencies to render with the non-default provider.
One example is if you wanted to render a specific JavaScript file with the OOTB lazy load provider which will asynchronously go and fetch the JavaScript file from the server and load it into the DOM.
Example in MVC:
@{Html.RequiresJs(new JavascriptFile("~/Js/SomeLazyLoadScript.js") { ForceProvider = "LazyLoadRenderer" }); }
@Html.Raw(Html.RenderJsHere("LazyLoadRenderer"))
Example in Webforms:
<CD:JsInclude runat="server" FilePath="~/Js/SomeLazyLoadScript.js" ForceProvider="LazyLoadProvider" />
NOTE: that the provider names between MVC and Webforms will be different which you can see in the CDF configuration.