【发布时间】:2015-03-28 20:54:07
【问题描述】:
我有一个文本区域 (id=output2),其中包含一个数字列表。我有将数据写入文本文件的 ASP 代码,如果我指定文本,它就可以工作。
写入文本文件的代码:
<%
function WriteToFile(FileName, Contents, Append)
on error resume next
if Append = true then
iMode = 8
else
iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing
end function
%>
然后这段代码会覆盖文件并插入数据并且可以工作:
<%
WriteToFile "C:\INSTALL\Test1.txt", "Why is this so difficult??", False
%>
但是,如果我不理会第一个代码并尝试从 textarea 字段中获取动态数据,它会失败且没有错误。甚至不触摸文本文件。我尝试了很多方法...这里有五个失败的方法:
1:
<%
WriteToFile "C:\INSTALL\Test1.txt", Document.getElementById("output2"), False
%>
2:
<%
dim texttoinsert
texttoinsert = Document.getElementById("output2")
WriteToFile "C:\INSTALL\Test1.txt", texttoinsert, False
%>
3:
<%
WriteToFile "C:\INSTALL\Test1.txt", Response.Write(Document.getElementById("output2")), False
%>
4:
<%
dim texttoinsert
texttoinsert = "Starting to hate this"
WriteToFile "C:\INSTALL\Test1.txt", texttoinsert, False
%>
5:
<%
dim texttoinsert
texttoinsert = "Definitely hate this"
WriteToFile "C:\INSTALL\Test1.txt", Response.Write(texttoinsert), False
%>
我什至做了一些能够利用 Document.getElementById 的 VBscript,但我不知道如何让它进入 ASP 代码。
【问题讨论】:
标签: vb.net asp-classic textarea writetofile