473,770 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3102
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.Rende rControl(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******** ********@TK2MSF TNGP15.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.Strin gWriter(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(sC ontent);
}

Nov 19 '05 #3

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

Similar topics

1
3094
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 void Page_Load(object sender, System.EventArgs e) { Page.RegisterHiddenField("__EVENTTARGET","SomeButtonOnThePage");
1
2543
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 available page template. Each template is a straight-forward HTML file (not an asp or aspx) When a user clicks on an icon, the text comprising the selected template's HTML file is read into a string variable that is then injected into a <DIV> tag...
4
6234
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 the server to a file. Any ideas would be appreciated. Thank you Paul
5
3136
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 click event will fire and the page will submit. I have a series of pages with Previous and Next navigational Btns. The Previous button is the first button, so when the user hits enter, the previous page is served up. Enter should result in...
1
1128
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 return a small amount of Html with another custom control tag inside this html. For example:
2
1781
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 running Apache 2.0.54 (Linux machine) I have a page that features an external stylesheet, as well as styling in the <style> element area of the document head, as well as element-specific
5
1362
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 CodeBehind="about.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Briggs.about" %> <%@ Register TagPrefix="uc1" TagName="WebUserControlSearch" Src="WebUserControlSearch.ascx" %>
1
1008
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 references if we ever changed them in production down the road. Is there a better way to do this? A few other options I was considering: 1. Taking an image of the data - jpeg, tiff etc... 2. Converting to pdf - size may get unwildy though
3
1893
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 Master Page, which would call a Javascript function to display a message if a hidden field contained a value other than a null string. Well, of course I discovered that the Body onload event only happenned upon initial load of the page.
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.