I would like to keep a single header file for all 15K pages. However, the <h1>Title</h1> in the header should be personalized according with the individual pages. I wonder if it's possible to read values from specific tags in the <head></head> section of each page and write it as HTML in the document’s body? I'm novice in ASP coding so please include some mercy with your help
Yes it possible step 1) Load your file for read Step 2) Find <head> starting posion and end posision </head> using substring step 3) now open your file in update mode and add one line <h1>var1</h1> step 4)update file tack back up file before do
Sub WriteToFile(strFilePath, strData, iLineNumber) Dim objFSO, objFile, arrLines Dim strAllFile, x Set objFSO=Server.CreateObject("Scripting.FileSystemObject") strAllFile="" If objFSO.FileExists(strFilePath) Then Set objFile=objFSO.OpenTextFile(strFilePath) If Not(objFile.AtEndOfStream) Then strAllFile = objFile.ReadAll End If objFile.Close End If arrLines = Split(strAllFile, VBCrLf) Set objFile=objFSO.CreateTextFile(strFilePath) For x=0 To UBound(arrLines) If (iLineNumber-1)=x Then objFile.WriteLine(strData) objFile.WriteLine(arrLines(x)) Next If iLineNumber>=UBound(arrLines) Then objFile.WriteLine(strData) objFile.Close Set objFile=Nothing Set objFSO=Nothing End Sub 'usage: Call WriteToFile(Server.MapPath("log.txt"), Request.ServerVariables("REMOTE_ADDR"), 5) Code (markup):
use a master page in asp.net and then in the page_load of your content page add page.title = "My page" . You can also add any metatags using much the same method.
Thank you so much for replying, John. As I promissed in my original post - I've absolutely no clue as to what you've just said. Can you please repeat it in an ASP for Dummies jargon?
On my site www.new-york-hotels.net I just a template system, where I open a static html file and read it, do a search and replace on place holders and then write it to the new asp page. My template page can be seen here: www.new-york-hotels.net/template/template.html. Alot of the code to do this and other functions I cant show but below is a simple version. First you need a html template called "template.html" Then you need an asp file <% ' Here we open the HTML File Set myFileSystem = Server.CreateObject("Scripting.FileSystemObject") Set myHtmlFile = myFileSystem.GetFile(server.MapPath("template.html"))' (server.MapPath("template.html")) Set objTextStream = myHtmlFile.OpenAsTextStream(1,0) ' Here we read all of it strHtmlPage = objTextStream.ReadAll ' Close the file system connection Set myFileSystem = Nothing Set myHtmlFile = Nothing Set objTextStream = Nothing ' Here we do a search and replace. strHtmlPage = Replace(strHtmlPage, "<h1></h1>", "<h1>PAGE TITLE</h1>") ' Split the page into two aryPageTemplate = Split(strHtmlPage,"###Content###",-1) ' Now we write the code into the new asp file Response.Write(aryPageTemplate(0)) %> BLAH BLAH <% Response.Write(aryPageTemplate(1)) %> Code (markup): What that will do is search for empty h1 tags and replace it with the PAGE TITLE then split the page at the ###Content### text and write the first and second halfs around the blah blah text.