asp file handling

Results 1 to 5 of 5

Thread: asp file handling

  1. #1
    Hamsa Guest

    Default asp file handling

    I want to replace the contents of an existing html file with new contents. In other words, I want the contents keyed in by the user to automatically overwrite the contents of the existing page in the same format. How do I do this? <BR>Consider this example. I have a html file called sample.htm<BR>ie &#060;html>&#060;head>&#060;title>mypage&#060;/title>&#060;/head>&#060;/html><BR>In this file I want the title `mypage&#039 to be replaced with whatever title the user wants, say for eg. `David&#039s page&#039. How do I do it? <BR>

  2. #2
    Chris Willey Guest

    Default RE: asp file handling

    &#060;%<BR>Dim myFS, myFile<BR>Set myFS = CreateObject("Scripting.FileSystemObject")<BR>Set myFile = myFS.OpenTextFile("c:sample.htm", 2)<BR>myFile.WriteLine("&#060;html>&#060;head>&#06 0;title>")<BR>myFile.WriteLine("mypage") &#039replace with your contents<BR>myFile.WriteLine("&#060;/title>&#060;/head>&#060;/html>")<BR>myFile.Close<BR>&#037;&#062;<BR><BR>Whe n you use the OpenTextFile method of a FileSystemObject, you use the first parameter after the file name to determine how you want to handle the file. A "1" indicates reading, "2" is for writing (original contents are lost), and "8" is for appending.

  3. #3
    Join Date
    Dec 1969

    Default RE: asp file handling

    This is not the way he should go about his problem. Basically, what he wants is a page that is customized for every user. You will want a database table with an association between a particular user and the title for the page.<BR><BR>When the person "logs in" (this can be through a username/password or cookies), you would reload the main page, hitting the database, getting the title, and putting it in the right place.<BR><BR>Does this make sense?

  4. #4
    Lodewijk Guest

    Default RE: asp file handling

    Probably you read the other two responses, and are thinking of creating a new database for your clients. This is fine if you have the space for a new database.<BR>Another method is just by using PERL (probably faster and for only such a small task, perfect)<BR>Keep in mind that this is only interesting if you don&#039t want to remember the clients customized settings (if you want to remember them, Scott&#039s way is better). <BR>Possible solution:<BR> -> reads template.html and changes the anchor &#060;!--TITLE--> with &#039mytitle&#039 and than flushes the file to the user<BR>Watch out for glueing to much with ASP and PERL......can be confusing.

  5. #5
    Deion (Aaron T. Lange) Guest

    Default RE: asp file handling

    hehe.. and just to make this more confusing, i will throw in another way... how about using ASP!? depending on how many of these vars you plan on making custimizable you could just have the user keyin the info in a form then use ASP requests to display the HTML text in the areas you want overwriten. ie.<BR>&#060;html>&#060;head>&#060;title>&#060;%=r equest.querystring("mypage")&#037;&#062;&#060;/title>&#060;/head>&#060;/html> where mypage was a text box filled in by the user. <BR>this is unless your talking about always displaying the same mypage title and only having the user key it in once.. then i would suggest you use a database/txt file.<BR><BR>*throws his 2 cents in*<BR>~Deion<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts