473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I saved page content to file?

I am generating asp.net page and need to send content of this page
(html) via email as attachment.
I have tried:
System.Web.HttpContext.Current.Request.SaveAs(Serv er.MapPath(".") + "\
\test.html", true);

but it has no actual page content.

Thanks

Feb 13 '07 #1
2 1526
The request object is what is requesting your page, that will not help at all.
The Page class derives from Control, and this offers the RenderControl method.
If you search around you can find some examples of how to use that , handle
errant <FORMtags, and save the resulting HTML to a file if desired, to be
used as an attachment.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"arkgroup" wrote:
I am generating asp.net page and need to send content of this page
(html) via email as attachment.
I have tried:
System.Web.HttpContext.Current.Request.SaveAs(Serv er.MapPath(".") + "\
\test.html", true);

but it has no actual page content.

Thanks

Feb 13 '07 #2
On Feb 13, 12:13 pm, "arkgroup" <arkgr...@hotmail.comwrote:
I am generating asp.net page and need to send content of this page
(html) via email as attachment.
I have tried:
System.Web.HttpContext.Current.Request.SaveAs(Serv er.MapPath(".") + "\
\test.html", true);

but it has no actual page content.

Thanks
I usually do the following to get the html from a page.

StringBuilder sb = new StringBuilder();
HtmlTextWriter htw =new HtmlTextWriter(new StringWriter(sb));

// Render the page to it
Render(htw);

string strHTML = sb.ToString();

you can then use strHtml as the body of an email or for saving to a
file.

Feb 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sugapablo | last post by:
I have two ASP pages. They basically query a database, and spit out the information as plain text in CSV format. The first has the SQL query hardcoded into it. The second takes a SQL query...
3
by: The Pritchard | last post by:
I want the user to be able to save the information displayed on a dynamically created page. When I write a script like the following: <SCRIPT> winNew = window.open("","test");...
32
by: Howard Kaikow | last post by:
I often come upon web pages that do not allow themselves to be saved as a ..html file (complete), but do allow themselves to be saved as .mht files. In some cases, I find that there is no way to...
2
by: Sam White | last post by:
I have set up a MySQL db on one server, IIS 6.0 on another. Using Frontpage I created some forms to input data. On a test page I made, I have 4 fields. First is the ID which is autonumber (I leave...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: Ken Sturgeon | last post by:
In VS2005 I have a loop that grabs all of the html from a number of web pages and saves them as files on a local drive. While all of the files get saved, several of the files are empty, although I...
15
by: Sharon | last post by:
I have an XML question: I'm have an XML node of type PointF and when it's saved to a file by XmlDocument.Save(...) it saves as I expect it to be saved: <ImageOrigin>{X=1.2,...
1
by: WT | last post by:
Hello, I have a dictionary made with objects which contain a control element, the control element is added to a Page when I want to edit the dictionary content. I put this dictionary in cache...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.