| | |
save .aspx page as .html file
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
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()
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()
•
•
Join Date: Sep 2004
Posts: 13
Reputation:
Solved Threads: 1
0
#2 Nov 9th, 2009
I'm not 100% sure of what you are trying to do. Do you basically want to output a plain html file from a .aspx page? There are a few ways you could go about doing this. I changed your code around a little bit and this works on a test page that I put together:
The file path would be the location of the html file on the server. If you can post more details about what you are trying to accomplish it would help.
Hope this helps.
ASP.NET Syntax (Toggle Plain Text)
Response.Clear() Response.Buffer = True Response.ContentType = "text/html" Response.ContentEncoding = System.Text.Encoding.UTF8 Dim htmlReader As New System.IO.StreamReader("absolute file path of the html file you want to display") Response.Write(htmlReader.ReadToEnd()) htmlReader.Close()
The file path would be the location of the html file on the server. If you can post more details about what you are trying to accomplish it would help.
Hope this helps.
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#3 Nov 9th, 2009
i need to actually Write the .html file contents to a virtual folder. such as Dim vpath As String = Server.MapPath("myFile"). as soon as the user navigates to the .aspx page - they could still see that page. i just need some additional processing to "save" that as a separate .html file, without intervention from the user. hopefully that's a little more clear as to what im trying to do. thanks again. rik
-7
#5 Nov 10th, 2009
•
•
•
•
i guess the "short" of it would be i want to by-pass the save-file-dialog (so the user is not involved) and save to a pre-determined folder
If i am helpful, please give me reputation points.
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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()
how to give the .aspx page as the input to this coding
•
•
Join Date: Sep 2009
Posts: 55
Reputation:
Solved Threads: 11
0
#8 34 Days Ago
Not sure try like
ASP.NET Syntax (Toggle Plain Text)
this.rendercontrol()
Chandru
SilverlightScripting.com
SilverlightScripting.com
![]() |
Similar Threads
- Embed html file in aspx page and highlight the input text (ASP.NET)
- Accessing control from an aspx page to a seperate .vb class file (ASP.NET)
- How do I output information from a PHP page to an HTML page? (PHP)
- Combining CSS and Javascript files into single HTML file [HELP NEEDED] (JavaScript / DHTML / AJAX)
- how to make the aspx page at runtime (ASP.NET)
- How to create a html page from a txt file (Python)
- Create .aspx page at runtime (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Transfer data between pages
- Next Thread: Redirect a page in a frame target
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox click commonfunctions confirmationcodegeneration css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal forms formview google grid gridview gudi iframe iis javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox rotatepage save schoolproject search security select silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers






