locked
What code to write to save webpage as htm? RRS feed

  • Question

  • User526999632 posted

    Hi everyone,

     I was wondering if there was a way to write code for a button on a webpage to save the page (dynamic aspx) as a htm page and maybe giving the saved htm page a custom name.

    I am working in VB VS2005

    Please help.

     Joel

    Sunday, April 13, 2008 11:12 AM

Answers

  • User-158764254 posted

    File.Create is just a wrapper around a FileStream so use whichever one you're comfortable with. Here's another short article where the author was grabbing some output and then writing it to disk.  You should be able to incorporate the code he used the write to a file.

    http://vivekthangaswamy.blogspot.com/2007/02/generate-html-file-as-output-of.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2008 7:51 PM
  • User-158764254 posted

    for turning your html into rtf, you'll need a convertor.  If you google a bit, you should find a number of 3rd party convertors.  I havent used any of them so i cant specifically recommend anything.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2008 11:07 PM

All replies

  • User-158764254 posted

    Here's an article about emailing an aspx page.  the technique used her to capture the generated markup should work for you as well and then instead of emailing it, you could save it to disk.

    http://aspnet.4guysfromrolla.com/articles/122006-1.aspx

     

    Sunday, April 13, 2008 1:26 PM
  • User526999632 posted

    Thanks Mike for your answer, this article was very helpfull in terms of understanding how to render a control in ASP.Net.

     The things I still am not sure is how to save the rendered markup as a .htm page?

    Thanks,

     Joel

    Sunday, April 13, 2008 7:05 PM
  • User526999632 posted

    Do I use the System.IO.FileStream method?

    Sunday, April 13, 2008 7:06 PM
  • User526999632 posted

    I guess the File.Create would be a better option? What do you suggest?

    Thanks

    Joel 

    Sunday, April 13, 2008 7:14 PM
  • User-158764254 posted

    File.Create is just a wrapper around a FileStream so use whichever one you're comfortable with. Here's another short article where the author was grabbing some output and then writing it to disk.  You should be able to incorporate the code he used the write to a file.

    http://vivekthangaswamy.blogspot.com/2007/02/generate-html-file-as-output-of.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2008 7:51 PM
  • User526999632 posted

    Thnks Mike, thats work perfectly..

    next question is what isthe best way to also save the file as .rtf for word.

    thankyou,

     Joel

    Sunday, April 13, 2008 10:45 PM
  • User-158764254 posted

    for turning your html into rtf, you'll need a convertor.  If you google a bit, you should find a number of 3rd party convertors.  I havent used any of them so i cant specifically recommend anything.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2008 11:07 PM
  • User723666645 posted

    Just this two line is enough to save webpage as htm.

     

    Dim webClient As New System.Net.WebClient    

    webClient.DownloadFile("http://localhost:51189/ppp.aspx?psno=103", "D:\Jaison\Download\lcal.html")

    Tuesday, March 26, 2013 1:36 AM