473,396 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Textbox editing...

I know how to read a file system object and output it to the browser page.
The desired result would be to put that file into a textbox on the screen
for a user to modify and then write the file back to the file system. The
concept seems simple enough, read the text file into a variable then some
magic asp will put it into a textbox value, then somehow take that value and
write the file. I know how to write files to the system as well. I am
missing a key piece.. any ideas?

Thanks,
Ketta
Jul 19 '05 #1
6 2237
Alright, you have the file in a textbox already, so once the user submits
the file, take the request.form("thatTextbox"), create an FSO object, and
overwrite the existing file with the contents from that textbox.

Ray at home

"Ketta" <no@post.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I know how to read a file system object and output it to the browser page.
The desired result would be to put that file into a textbox on the screen
for a user to modify and then write the file back to the file system. The
concept seems simple enough, read the text file into a variable then some
magic asp will put it into a textbox value, then somehow take that value and write the file. I know how to write files to the system as well. I am
missing a key piece.. any ideas?

Thanks,
Ketta

Jul 19 '05 #2
Well thanks for that part, that will definately help me. But I still do not
have the file in a textbox. It just outputs it to the screen. This is my
code for reading the file and putting it on the screen. I'm a total noob
with ASP btw. This is probably just annoying to have someone like me asking
for help. Now all I need is the code below to output to a textbox....
somehow.
<%
set fso = server.createobject("Scripting.FileSystemObject")
set fs = fso.openTextFile("textfile.txt",1,true)
response.write replace(replace(fs.readall,"<","<"),vbCrLf,"<br>")
fs.close: set fs = nothing: set fso = nothing
%>

Thank you
Ketta

"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:eZ**************@TK2MSFTNGP09.phx.gbl...
Alright, you have the file in a textbox already, so once the user submits
the file, take the request.form("thatTextbox"), create an FSO object, and
overwrite the existing file with the contents from that textbox.

Ray at home

"Ketta" <no@post.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I know how to read a file system object and output it to the browser page. The desired result would be to put that file into a textbox on the screen for a user to modify and then write the file back to the file system. The concept seems simple enough, read the text file into a variable then some magic asp will put it into a textbox value, then somehow take that value

and
write the file. I know how to write files to the system as well. I am
missing a key piece.. any ideas?

Thanks,
Ketta


Jul 19 '05 #3

"Ketta" <no@post.net> wrote in message
news:OH*************@tk2msftngp13.phx.gbl...
Well thanks for that part, that will definately help me. But I still do not have the file in a textbox. It just outputs it to the screen. This is my
code for reading the file and putting it on the screen. I'm a total noob
with ASP btw. This is probably just annoying to have someone like me asking for help.
If I were annoyed, I wouldn't use newsgroups. :]
Now all I need is the code below to output to a textbox....
somehow.
<%
set fso = server.createobject("Scripting.FileSystemObject")
set fs = fso.openTextFile("textfile.txt",1,true)
response.write replace(replace(fs.readall,"<","<"),vbCrLf,"<br>")
fs.close: set fs = nothing: set fso = nothing
%>


You can just server.execute the contents of the file, i.e.

http://yoursite/filemod.asp?filename=file.txt :
<%
sFilename = Request.Querystring("filename")
%>

<html>
<form method="post" action="filemodp.asp">
<input name="filename" value="<%=sFilename%>" type="hidden">
<textarea name="fileContents" style="width: 500px; height: 800px;"><%
Server.Execute sFilename %></textarea>
<input type="submit">
</form>

http://yoursite/filemodp.asp :
<%
Dim sFilename, sContents
sFilename = Request.Form("filename")
sContents = Request.Form("fileContents")
If sFilename <> "" Then
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(Server.MapPath(sFilename), True)
oFile.Write sContents
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
End If

Response.Redirect "filemod.asp?filename=" & sFilename
%>
Play around with that to see what I mean. But, what you'll want to do first
is create a file named "file.txt" throw a few characters into it, and then
load up the filemod.asp page with the ?filename=file.txt querystring. This
sample has no handling of errors for empty or non-existant files.

Ray at work

Jul 19 '05 #4
"Ketta" <no@post.net> wrote in message
news:OH*************@tk2msftngp13.phx.gbl...
Well thanks for that part, that will definately help me. But I still do not have the file in a textbox. It just outputs it to the screen. This is my code for reading the file and putting it on the screen. I'm a total noob with ASP btw. This is probably just annoying to have someone like me asking for help. Now all I need is the code below to output to a textbox....
somehow.


Wrap the file content in textarea tags like so:

<%
set fso = server.createobject("Scripting.FileSystemObject")
set fs = fso.openTextFile("textfile.txt",1,true)
Response.Write "<textarea name='myTextArea' cols='80' rows='10'>"
Response.Write fs.readall
Response.Write "</textarea>"
fs.close: set fs = nothing: set fso = nothing
%>

HTH
-Chris Hohmann

P.S. Your question was not annoying and you don't need to apologize for
being new to ASP. Everyone was once. :) Hope to hear from you again.
Jul 19 '05 #5
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
You can just server.execute the contents of the file, i.e.

http://yoursite/filemod.asp?filename=file.txt :
<%
sFilename = Request.Querystring("filename")
%>

<html>
<form method="post" action="filemodp.asp">
<input name="filename" value="<%=sFilename%>" type="hidden">
<textarea name="fileContents" style="width: 500px; height: 800px;"><%
Server.Execute sFilename %></textarea>
<input type="submit">
</form>


This introduces a significant security hole in the system since it
allows the end user to post/execute code of their choosing. I would
stick with using the FSO.

-Chris Hohmann
Jul 19 '05 #6
That is quite true.

Ray at work

"Chris Hohmann" <no****@thankyou.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:O$**************@tk2msftngp13.phx.gbl...
You can just server.execute the contents of the file, i.e.

http://yoursite/filemod.asp?filename=file.txt :
<%
sFilename = Request.Querystring("filename")
%>

<html>
<form method="post" action="filemodp.asp">
<input name="filename" value="<%=sFilename%>" type="hidden">
<textarea name="fileContents" style="width: 500px; height: 800px;"><%
Server.Execute sFilename %></textarea>
<input type="submit">
</form>


This introduces a significant security hole in the system since it
allows the end user to post/execute code of their choosing. I would
stick with using the FSO.

-Chris Hohmann

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
2
by: Martin Hazell | last post by:
For various reasons, I have had to produce a quick (!) page to edit one column of data in a database with ASP.net. With this being my first foray into ASP.net, I apoligise for any basic erros I have...
4
by: Jason Cowsill | last post by:
Hi - I am looking for a way to dynamically alter a textbox WHILE the user is typing in it. One example would be while a user is entering their phone number a dash would be entered automatically...
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
7
by: Cemal Karademir | last post by:
Hello, Please forgive my simple question, but i don't know the correct synatx. From the masterpage i want to put a text in an textbox and then select an item in the datagrid. I do know how to...
2
by: donnet | last post by:
Inside my .aspx file, I have a textbox populated with data from a dataset like this: <asp:TextBox text='<%# DataBinder.Eval(Container.DataItem, "Comment")%>' id="CommentText" runat="server"...
2
by: H. Blijlevens | last post by:
Hi y'all! I'm trying to adapt a VB.Net application that a former employee built to keep track of product issues that our customers report. While doing so, I bump into the following problem: a...
0
by: Silver Oak | last post by:
I have a DataGrid in which one of the columns is TemplateColumn that was created dynamically using iTemplate. I would like to have multi-row editing capability on the DataGrid. I'm trying to...
2
by: zacks | last post by:
I am developing an app in VS2005 (actually in VB.NET but this question, I believe, would apply to any .NET language) that is used to design the contents of an XML file. One of potential items that...
4
by: Finn Stampe Mikkelsen | last post by:
Hi Is there any way to make the textbox property show html, like a textarea on a webpage would?? I have a webapplication that saves an textarea complete with html tags and everything... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.