我有如下代码
Public cs As ClientScriptManager
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cs = Page.ClientScript
cs.RegisterArrayDeclaration("activArray", """asd"",""ert"",""sdt""")
End Sub
//"text/javascript"
function doInit() {
alert(activArray.length)
}
在运行这些代码时,它显示一个错误
Microsoft JScript运行时错误:'activArray'未定义
请帮助我解决此错误。谢谢
最佳答案
只需使用\
转义数组字符串即可:
cs.RegisterArrayDeclaration("activArray", "\"asd\","\"ert\","\"sdt\"")