save .aspx page as .html file

i have looked and looked for this and so far all the code i've downloaded simply doesnt work.
this code (below) works fine - however it opens up the "save file Dialog" and requires that the user select the path to save the .html file.
how can i by-pass that and save the file myself to say - a virtual directory?
any help is greatly appreciated
thanks
rik

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/html"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=Test.html")
Response.Charset = ""
EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
pnMyPanel.RenderControl(oHtmlTextWriter)
Response.Write(oHtmlTextWriter.ToString())
Response.Close()

Comments

  • hi,

    i'm trying to do this but i need the definition type of tthe pnMyPanel variable.

    thks
  • sorry, it's a aspx .Net control.
    basically,


    thanks
    rik
  • i went another way with this basically assembling the .aspx page thru string builder. then passing it to
    the IO StreamWriter Object. Not Elegant but it does work.
    thought i would post this as a follow up.
    thanks again
    rik
    Private Sub WriteHtmlFile(ByVal myPage As String, ByVal myFileName As String)

    Dim myHtmlWriter As System.IO.StreamWriter
    Dim myFile As String
    myFile = myFileName.ToString
    myHtmlWriter = System.IO.File.CreateText("C:" & myFile & ".html")
    Dim myFilePath As String = ("C:" & myFile & ".html")
    myHtmlWriter.Write(myPage.ToString)
    myHtmlWriter.Close()
    End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories