vb.net - ASP Writing Values from Textbox to Textfile -


i have textarea (id=output2) has list of numbers in it. have asp code writes data text file , works if specify text.

code write text file:

<% function writetofile(filename, contents, append) on error resume next  if append = true    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  %> 

then code overwrites file , inserts data , works:

<% writetofile "c:\install\test1.txt", "why difficult??", false %> 

but yet if leave first code alone , try dynamic data such textarea field fails no error. doesn't touch text file. tried many many ways... here 5 failed:

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 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 %> 

i did vbscript able tap document.getelementbyid couldn't figure out how go asp code.

document.getelementbyid doesn't have meaning in server-side code. have submit form pass data function page , use this:

html page:

<form action="myfunction.asp"> <input name="texttoinsert"> <input type="submit" value="write data"> </form> 

myfunction.asp

<% function writetofile(filename, contents, append)  on error resume next  if append = "true"     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  texttoinsert = request("texttoinsert") writetofile "c:\install\test1.txt", texttoinsert, false %> 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -