【发布时间】:2010-07-26 22:05:35
【问题描述】:
我正在开发一个需要使用 Lightbox 的自定义 DotNetNuke 模块。将 Lightbox 所需的 javascript 添加到 DNN 模块的最佳方法是什么?
我见过的几乎所有解决方案都涉及将 javascript 引用添加到皮肤文件。还有另一种方法可以做到这一点吗?即使对于不需要它们的模块,我也不希望加载这些 javascript 文件。
================================================ =======================
感谢 spinon 的帮助,这是我正在使用的解决方案:
Dim csMgr As ClientScriptManager = Page.ClientScript
Dim Name As String = "prototype.js"
Dim ScriptPath As String = "http://dnn/js/prototype.js"
Dim Type As Type = Me.GetType
'check if script is already registered
If Not csMgr.IsClientScriptBlockRegistered(Type, Name) Then
Dim scriptText As New StringBuilder
scriptText.AppendLine()
scriptText.Append("<script src=""")
scriptText.Append(ScriptPath)
scriptText.Append(""" type=""text/javascript""></script>")
scriptText.AppendLine()
'register script
csMgr.RegisterClientScriptBlock(Me.GetType, Name, scriptText.ToString())
End If
【问题讨论】:
-
还有另一种方法,将你的js放在模块根目录中并使用:
标签: .net javascript lightbox dotnetnuke