c# 4.0 - how to Call Javascript file in dotnetnuke -
i new in dot net nuke when adding java script file on user control not loading while other java script loading have tried on both ascx , code behind.so have code load java script fie given below code
protected void page_init(object sender, eventargs e) { try { page.clientscript.registerclientscriptinclude("news", resolveurl("~/script/news.js")); // clientresourcemanager.registerscript(this.page, "~/script/" + "news.js", 101, "dnnpageheaderprovider"); // clientresourcemanager.registerscript(this.page, "~/script/" + "newsscript.js", 101, "dnnpageheaderprovider");//105, page label js after global js } catch (exception ex) { this.logexception("error_pageload", ex); } }
if usercontrol view in custom module , script in local folder in module, best practice use dnn's client resource management api register javascript on page.
so, example, if module project looks this:
desktopmodules/[modulename] -view.ascx -view.ascx.cs -js/module.js -css/module.css
you can add following code view.ascx.cs:
using dotnetnuke.web.client.clientresourcemanagement; protected void page_prerender(object sender, eventargs e) { clientresourcemanager.registerstylesheet(this.page, base.controlpath + "css/module.css", dotnetnuke.web.client.fileorder.css.defaultpriority); clientresourcemanager.registerscript(this.page, base.controlpath + "js/module.js", dotnetnuke.web.client.fileorder.js.defaultpriority); }
Comments
Post a Comment