Click to See Complete Forum and Search --> : ASP output buffer?
David Harrison
10-07-2004, 07:14 AM
Hi there all. I was wondering, is there something in ASP that is similar to PHP's output buffer (I think that's what it's called).
Basically what I want to do is grab the source of the page after it has all been written, then replace a few bits of it.
javaNoobie
10-07-2004, 11:40 PM
I doubt there is anything in asp that can do that. Still I would love to see any solutions.
The best you can do(to the extend of my limited asp knowledge) is to change the page WHILE its being written instead of AFTER. Here's a quick example:
<%
Dim writeWhich
writeWhich = false
If (writeWhich) Then 'if true render a text box
%>
<input type="text">
<%
Else 'if false render a button
%>
<button>Click</button>
<%
End If
%>
russell
10-08-2004, 02:03 AM
Well, you can do it if you build your html in one big string...
Dim str
str = "<html>" & vbCrLf
str = str & "<body>" & vbCrLf
str = str & "Hello World" & vbCrLf
str = str & "</body>" & vbCrLf
str = str & "</html>" & vbCrLf
str = replace(str, "Hello", "Hi There")
Response.Write str
David Harrison
10-08-2004, 06:15 AM
Thanks guys but unfortunately I can't really do either of those things. The code is written by many functions in 6 different files and those functions are already complicated enough as it is.
CardboardHammer
10-08-2004, 11:21 AM
You might be able to slide another page in front of the one in question and open the page you want programmatically in the code of the new page, retrieving the raw HTLM of the page you want as a string and doing replacements as needed and then Response.Writing the resulting string as the content of the new page. You might also have to tweak the headers etc., depending on your situation.
EDIT: below are a couple links you may find useful
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmthopenixmlhttprequest.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmproresponsetextixmlhttprequest.asp