Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing ASP Processed HTML Code

Status
Not open for further replies.
Jan 26, 2001
550
GB
Hi Guys,

I don't know whether this can be done because I can't find the answer anywhere!

What I want to do is somehow 'grab' and save the html code that is sent to the browser after my asp page has been processed. I can find articles on how to save straight html files to a string, but not asp-processed code.

This would work essentially in the same way as the user right-clicking and viewing the code, then saving it to a html file, but it would be automated instead.

The reasoning behind this is that my asp page produces a layout for a html email advert, with products determined on the fly from an administration system. I want the user to then be able to email the resulting page as a html document.

I hope this makes sense, any suggestions would be gratefully received.

Thanks in advance!

Nick (Web Designer)

 
everything that is displayed to the client using Response.Write or in plain HTML from an ASP page can also be written to a flat html page. I have used this for generating flat HTML pages from databased content. when the database content changes, the site automatically generates fresh flat HTML pages that are search engine friendly.

Off home now but can post more tomorrow if you like
Tony
 
Hi Nick,

you can use the same page that sends the HTML to the browser to do your flat HTML page.

Here is a short example to which you can play with to your hearts content :)

Code:
<!-- #include file=&quot;include/functions.asp&quot; -->
<%
strFileName = &quot;c:\temp\generated.htm&quot;

Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.CreateTextFile(strFileName,True) 'create file - overwrite if it already exists
Set objDataRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strDataSQL = &quot;SELECT * FROM T_Sub&quot;

strContent = &quot;<HTML><HEAD><TITLE>Some Title Here</TITLE></HEAD><BODY>&quot; & vbcrlf 

objDataRS.Open strDataSQL, strConnect

While NOT objDataRS.EOF
  strContent = strContent & objDataRS(&quot;Sub&quot;) & &quot;<BR>&quot; & vbcrlf
  objDataRS.MoveNext
Wend

objDataRS.Close

strContent = strContent & &quot;</BODY></HTML>&quot;

Response.Write strContent 'write data to screen

objFile.WriteLine strContent 'write data to flat HTML page

Set objDataRS = Nothing
Set objFile = Nothing
Set objFSO = Nothing
%>


let me know if you need any more help

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top