CSS in DNN Modules

How can I add custom CSS and JavaScript for a specific module in DotnetNuke?

I understand that it does not look like a regular ASP.Net page.

+6
source share
2 answers

If your module has a file called module.css in the root folder of the module, it is automatically included on the page using the module.

For other CSS and for JavaScript, you should use Client Resource Management to enable the necessary resources. Something like that:

 <%@ Register TagPrefix="dnn"    Namespace="DotNetNuke.Web.Client.ClientResourceManagement"    Assembly="DotNetNuke.Web.Client" %> <dnn:DnnCssInclude runat="server"    FilePath="~/DesktopModules/MyModule/css/the-style.css" /> <dnn:DnnJsInclude runat="server"    FilePath="~/DesktopModules/MyModule/js/the-script.js" ForceProvider="DnnFormBottomProvider" /> 
+15
source

To add external JavaScript to a custom module:

 string externaJs= "externaJs"; Type cstype = System.Reflection.MethodBase.GetCurrentMethod().GetType(); string cstext = "<script src=\"" + ResolveUrl("~/DesktopModules/ModuleName/js/JsName.js") + "\" type=\"text/javascript\"></script>"; if (!Page.ClientScript.IsClientScriptBlockRegistered(externaJs)) Page.ClientScript.RegisterClientScriptBlock(cstype, externaJs, cstext, false); 
-2
source

All Articles