-1

I have two fields which are taken in two variables that are StrcategoryName and StrcategoryUrl means category name is stored in StrcategoryName and url is stored in StrcategoryUrl which are come from text file and then bind to input type text now i want two edit these data in textfile,

which are stored in text file. Now I want to edit these two fields

<tr>
   <th align="left" valign="middle" class="text" scope="row"><b>Enter Category Name:</b></th>
   <td align="left" valign="middle"><input type="text" name="txtcategoryname" value="<%=StrcategoryName%>" /></td>
</tr>
<tr>
   <th align="left" valign="middle" class="text" scope="row"><b>Enter Url Of Category Image :</b></th>
   <td align="left" valign="middle"><input type="text" name="txtName" value="<%=StrcategoryUrl%>"/></td>
</tr>

I have tried following code but I am getting an error.

balexandre
  • 73,608
  • 45
  • 233
  • 342
user1107760
  • 27
  • 1
  • 5

2 Answers2

0

Text manipulation is not easy, because it's always treated as a collection of lines that we need to parse line by line or know exactly what line holds what ... and someone come along and change the order ... it's not pretty!

That is why we always use XML to store data into files as the Framework gives us much more control on what is stored and it's easy to remove, edit, insert or delete something.

in Classic ASP, you have several tutorials that help you read and write XML files all over the web and several questions here at SO.

Asp XML Parsing

ASP Classic - XML Dom

and one from my favorite site back the days

Accessing XML Data using ASP

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
balexandre
  • 73,608
  • 45
  • 233
  • 342
  • its not a xml file i have used .txt file the how can i read and edit and then update and then save perticular data in that text file – user1107760 Dec 23 '11 at 07:10
  • I know, but you're going to end up with problems, it's better to use something that will avoid problems in the future. If you still think Text Files are the best approach, there are plenty of tutorials out there, this forum is to help, not to do work for you. [Try this for example](http://google.com/?q=classic+asp+text+file+read+write) – balexandre Dec 23 '11 at 08:33
  • you r right but i am uploading that page through ftp and ftp does not support to xml files anyway thanks – user1107760 Dec 23 '11 at 11:53
0

You need to use the "Scripting.FileSystemObject" to read/write textfiles using ASP. Most of the examples you will find on the web show you the contents of these text files by using Response.Write to display the values.

One of the better sites for learning how to read/write textfiles files is located here.

It sounds like you need to do for 4 things:

1. Read the text file using the Scripting.FileSystemObject and store the data into ASP variables
2. Place these variables into an HTML form that posts to an update page
3. On the update page obtain the updated values using the Request object
4. Save these new values to the text file using the Scripting.FileSystemObject