ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1704
Number of posts: 3262

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
save .aspx page as .html file Posted by rikb53 on 9 Nov 2009 at 10:26 AM
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()
Report
Re: save .aspx page as .html file Posted by Ginapierina on 16 Nov 2009 at 8:49 AM
hi,

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

thks
Report
Re: save .aspx page as .html file Posted by rikb53 on 16 Nov 2009 at 9:54 AM
sorry, it's a aspx .Net control.
basically,
<asp:Panel ID="pnMyPanel" Width="800" BorderColor="Black" BorderWidth="3px" runat="server">

thanks
rik
Report
Re: save .aspx page as .html file Posted by rikb53 on 3 Dec 2009 at 6:51 AM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.