How can I include JavaScript like Angular.js or any other JavaScript file in DNN 8 MVC module.
I am new to DNN but I had work experience on ASP.NET MVC.
Can you guide me through how to add JavaScript into my view (.cshtml) file.
I have seen that in this video have used ClientResourceManager.RegisterScript
method but 1st argument is System.Web.UI.Page
. What should I pass as this parameter?
Other way is to use JAVASCRIPT TOKEN
which I can see with this link but its not working as expectd in MVC module nor I am able to find any example to use it with MVC DNN 8 module.
Can you please help me with this?
If you use a module project template like Chris Hammond's, https://github.com/ChrisHammond/DNNTemplates/releases, that will show you the proper way to register your javascript and styles. But here is an example MVC view with the script registration:
@using DotNetNuke.Web.Client.ClientResourceManagement
@{
ClientResourceManager.RegisterStyleSheet(Dnn.DnnPage, "~/DesktopModules/MVC/DotNetNuclear/RestaurantMenu/Resources/bootstrap/css/bootstrap.min.css");
ClientResourceManager.RegisterScript(Dnn.DnnPage, "~/DesktopModules/MVC/DotNetNuclear/RestaurantMenu/Resources/bootstrap/js/bootstrap.min.js", 20);
ClientResourceManager.RegisterStyleSheet(Dnn.DnnPage, "~/DesktopModules/MVC/DotNetNuclear/RestaurantMenu/Resources/module.css");
}
I put this at the top of my .cshtml view above the html.