469,323 Members | 1,468 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

asp page to html

11
I'm working on a webapplication that is running asp with vbscript. I made a function that prints the current page to a pdf. I needed to add everything that I write to the browser into a string and give that string to the component. Not a hard task but quite annoying thou. I was wondering if there is an easy way to get the full generated html code into a string easier.
Now I make a new page and instead of response.write etc. I just add it to the string. This lowers performance and recalculates everything that was needed.

So it would be handy if I could have a button that just copys the current html page into a string. Any help or suggestions are highly appreciated.

Greetings woony
Dec 18 '07 #1
2 1005
Nicodemas
164 Expert 100+
You could use the XML HTTP Request COM to retrieve the response from the executed page.

I've written a little script for one of my own app's that will help you. The function will pass back the response text from the retrieved URL in string format. Just dump that into your PDF.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. '//===========================================
  3. '//
  4. '// Author: Robert "Nicodemas" Simpson
  5. '//
  6. '// Website: http:nicodemas.com
  7. '//
  8. '// Function [Boolean] XmlHttpRequest([in] string: sOperation,
  9. '//                                   [in] string: URL,
  10. '//                                   [in] string: XML,
  11. '//                                   [out]string: ResponseText)
  12. '//
  13. '// This function:
  14. '//      - executes a request to a remote URL, and
  15. '//      - returns the response thru arg. list.
  16. '//===========================================
  17.  
  18. function XmlHttpRequest(sOperation, URL, DataToSend, ResponseText)
  19.    dim oXml
  20.  
  21.    '//----------------------------------------------------
  22.    '// by default, function result is false
  23.    '//----------------------------------------------------
  24.    XmlHttpRequest = false
  25.  
  26.    sOperation = ucase(trim(sOperation))
  27.  
  28.    if sOperation = "" or (sOperation <> "GET" or sOperation <> "POST") then sOperation = "GET"
  29.    if URL = "" then exit function
  30.  
  31.    set oXml = server.createobject("microsoft.xmlhttp")
  32.  
  33.    oXml.open sOperation, URL, false
  34.    oXml.send DataToSend
  35.  
  36.    ResponseText = oXml.responsetext
  37.  
  38.    set oXml = nothing
  39.  
  40.    XmlHttpRequest = true
  41. end function
  42.  
  43. if XmlHttpRequest("GET", "http://url/to/the/page", "", theResponse) then
  44.    '// dump [theResponse] into your PDF
  45. end if
  46. %>
Dec 19 '07 #2
woony
11
thank u, I'll try it out
Dec 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Arun Nair | last post: by
2 posts views Thread by Jon Haakon | last post: by
1 post views Thread by Randi | last post: by
2 posts views Thread by John Lau | last post: by
6 posts views Thread by scottyman | last post: by
13 posts views Thread by Dan Aldean | last post: by
17 posts views Thread by =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.