Jam*_*mes 11 asp-classic type-mismatch
我有一个将HTML编码文本转换回HTML的功能.它通常运行良好,但出于某种原因,我尝试在今天的某些文本上使用它,并得到以下错误:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'UnChkString'
/manage/solutions_delete.asp, line 22
Run Code Online (Sandbox Code Playgroud)
我正在使用此功能的行是:
<%= UnChkString(solution_desc) %>
Run Code Online (Sandbox Code Playgroud)
该solution_desc变量是:
<p>Here is a description of what this solution is all about.</p>
Run Code Online (Sandbox Code Playgroud)
数据库solution_desc从中拉出的字段是文本字段.
我的UnChkString函数是:
Function UnChkString(string)
UnChkString = Replace(string,"[%]","%")
UnChkString = HTMLDecode(UnChkString)
End Function
Run Code Online (Sandbox Code Playgroud)
HTMLDecode函数是:
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, "&" , "&")
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "’", Chr(39))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
Run Code Online (Sandbox Code Playgroud)
编辑
我甚至尝试过:
<%= UnChkString(CStr(solution_desc)) %>
Run Code Online (Sandbox Code Playgroud)
没有运气.
有时最好只是仔细地重新阅读错误.考虑一下VBS:
DoStuff("Hello World")
Run Code Online (Sandbox Code Playgroud)
既然DoStuff没有定义也没有Option Explicit我得到:
错误:类型不匹配:'DoStuff'
你的错误是:Type mismatch: 'UnChkString'.它没有抱怨参数被传递其抱怨UnChkString自己.我的猜测是你已经提交了最基本的VBScript编程模式,你没有Option Explicit代码顶部.这是必须的.
由于到目前为止您发布的代码不清楚的原因,<%= UnChkString(solution_desc) %>正在执行的代码处的脚本引擎没有函数UnChkString,因此您看到的错误.我怀疑包含Option Explicit将揭示问题(以及强迫你Dim所有的变量).
我同意 Anthony 的意见,即您应该在 ASP 页面的顶部使用 Option Explicit。
我怀疑原因是缺少或格式错误的包含文件
我可以用下面的代码复制这个,我要么删除
<!--#include file="include-functions.asp"-->
Run Code Online (Sandbox Code Playgroud)
或通过将其更改为使呼叫畸形
<!-#include file="include-functions.asp"-->
include-functions.asp
<%
Function UnChkString(string)
UnChkString = Replace(string,"[%]","%")
UnChkString = HTMLDecode(UnChkString)
End Function
%>
index.asp
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<!--#include file="include-functions.asp"-->
<%
Dim solution_desc
solution_desc = "<p>Here is a description of what this solution is all about.</p>"
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, "&" , "&")
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "’", Chr(39))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
%>
<%= UnChkString(solution_desc) %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43195 次 |
| 最近记录: |