473,387 Members | 1,512 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,387 software developers and data experts.

How to capture the rendered HTML for asp.net page?

Hi - I want to be able to capture the html generated by one of my pages. Is
there any way to do this from within the application, or must I use some
form of 'screen-scraping'. If screen-scraping, can someone point me in the
right direction and indicate how I get past the login screen, etc.(uses
forms authentication)? Thanks,

Paul.
Nov 19 '05 #1
2 3081
You can get the HTML for a control using this code:

Dim SB as New StringBuilder()
Dim SW as New StringWriter(SB)
Dim htmlTW as New HtmlTextWriter(SW)
MyControl.RenderControl(htmlTW)
Dim MyHTML as String = SB.ToString()

You can get the HTML for an external web page with the WebRequest method:
http://msdn.microsoft.com/library/de...classtopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Paul W" <qq*@qqq.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi - I want to be able to capture the html generated by one of my pages.
Is there any way to do this from within the application, or must I use
some form of 'screen-scraping'. If screen-scraping, can someone point me
in the right direction and indicate how I get past the login screen,
etc.(uses forms authentication)? Thanks,

Paul.

Nov 19 '05 #2
Override the page's Render Method as follows:

protected override void Render (HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter tw = new HtmlTextWriter(new
System.IO.StringWriter(sb));
//Render the page to the new HtmlTextWriter which actually writes to
the stringbuilder
base.Render(tw);

//Get the rendered content
string sContent = sb.ToString();

//Now output it to the page, if you want
writer.Write(sContent);
}

Nov 19 '05 #3

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

Similar topics

1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
1
by: Hose B | last post by:
HI all, I have a legacy app in which users can pick various page templates. There is a template preview dialog. It works such that they view a list of icons in an asp page that represent each...
4
by: Paul | last post by:
I have developed an ASP.NET web page with a VB.net for the code behind. I would like to redirect the output of the web page so I can send it as an Email. Or Redirect the HTTPResponse stream on...
5
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
1
by: SlimFlem | last post by:
I hope this makes sense. Here is what I am attempting. I have an inital generic aspx page that has one custom tag: <web:site id=webSite runat=server/> When this control evaluates, it will...
2
by: Patient Guy | last post by:
I don't think I have ever encountered something like this before. On a Windows XP running Apache 2.0.53 I do my page development (XP machine). I then upload the stuff to a Linux/Redhat/Fedora...
5
by: homertbush | last post by:
When our asp.net pages are rendered out as html the page directive is still in the html. ie. The following page directive is present in the body of the html of the rendered page: <%@ Page...
1
by: Rob Schieber | last post by:
Hello, Our company needs to capture output presented to the user. Its a web app, so we are looking into storing html in a datawarehouse. The problem is that we would lose any css or external...
3
by: John Kotuby | last post by:
Hi all, I am converting an ASPX 3.5 page in VB and VS 2008 from the standard postback to callbacks using an UpdatePanel. I had originally been adding an onload attribute to the Body tag in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.