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

How to retrieve HTML in ASPX page

naz
Hello,

Is it possible to retrieve the HTML which gets dynamically created in
an ASPX file and presented to the client? I need to do this from the
server.

Thanks

Naz
Nov 17 '05 #1
6 5145
you mean dynamically generating allhtml ?

Response.Clear
set conent type to text/html (Response.AddHeader AFAIR)
write to response stream, close it

HTH
-----Original Message-----
Hello,

Is it possible to retrieve the HTML which gets dynamically created inan ASPX file and presented to the client? I need to do this from theserver.

Thanks

Naz
.

Nov 17 '05 #2
try this

StringWriter sw;
HtmlTextWriter htmltw;
sw = new StringWriter();
htmltw = new HtmlTextWriter(sw);
base.Render(htmltw);
StringBuilder temp = sw.GetStringBuilder();
--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"naz" <na**@bigfoot.com> wrote in message
news:35**************************@posting.google.c om...
Hello,

Is it possible to retrieve the HTML which gets dynamically created in
an ASPX file and presented to the client? I need to do this from the
server.

Thanks

Naz

Nov 17 '05 #3
naz
Hi John

Thanks for your help. I tried using your code:
StringWriter sw;
HtmlTextWriter htmltw;
sw = new StringWriter();
htmltw = new HtmlTextWriter(sw);
base.Render(htmltw);
StringBuilder temp = sw.GetStringBuilder();


But when it tries to render the html, I get the following error:

"A page can have only one server-side Form tag. "

and:

"Exception Details: System.Web.HttpException: A page can have only one
server-side Form tag."

I do have only 1 Server Side Form Tag! And I tried reading about
base.Render in MSDN with little luck.

Any ideas why I'm getting this error on Render?

Thanks and Regards

Naz
Nov 17 '05 #4
naz
Hi Konrad,
you mean dynamically generating allhtml ?
I need to get the HTML that was dynamically generated in an ASPX page.
Response.Clear
set conent type to text/html (Response.AddHeader AFAIR)
write to response stream, close it


Thanks for the advice but can you show me an example? I am having
difficulty finding an example (or documentation) that will allow me to
retrieve the HTML content of an aspx page after it is dynamically
built. This is all new to me!

Thanks

Naz
Nov 17 '05 #5
I can think of a very simple way to get the html. i.e. create a httprequest
(programmatic page request). And out comes the html in the response.

"naz" <na**@bigfoot.com> wrote in message
news:35**************************@posting.google.c om...
Hi John

Thanks for your help. I tried using your code:
StringWriter sw;
HtmlTextWriter htmltw;
sw = new StringWriter();
htmltw = new HtmlTextWriter(sw);
base.Render(htmltw);
StringBuilder temp = sw.GetStringBuilder();


But when it tries to render the html, I get the following error:

"A page can have only one server-side Form tag. "

and:

"Exception Details: System.Web.HttpException: A page can have only one
server-side Form tag."

I do have only 1 Server Side Form Tag! And I tried reading about
base.Render in MSDN with little luck.

Any ideas why I'm getting this error on Render?

Thanks and Regards

Naz

Nov 17 '05 #6
naz
Hello,

I got it working. In case anyone is interested, here is the code:

-----------------------------------------------------------------------
string path = System.Web.HttpContext.Current.Request.Url.Absolut eUri;//.FilePath;

HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(path);
loHttp.Timeout = 10000; // 10 secs
loHttp.UserAgent = "Code Sample Web Client";

loHttp.CookieContainer = new CookieContainer();

HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();

Encoding enc = Encoding.GetEncoding(1252); // Windows-1252 or iso-
if (loWebResponse.ContentEncoding.Length > 0)
{
enc = Encoding.GetEncoding(loWebResponse.ContentEncoding );
}

StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream(),enc );

string html = loResponseStream.ReadToEnd();

loResponseStream.Close();
loWebResponse.Close();

-----------------------------------------------------------------------
Naz
Nov 17 '05 #7

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

Similar topics

4
by: Fre | last post by:
Hi, i made script with an alert window that should show me the location of the page in frame CONTENT (..../artikels.aspx). But it don't work, i got an error: 'top.frames.1.frames' is empty or nog...
1
by: zoltix | last post by:
Hi, How to retrieve a value in in an aspx page? Normally it is easy, drag and drops the textarea in aspx page and it is work. But in this case, I generate the html code manually () and put as...
5
by: Kathy Burke | last post by:
Hello. I have an aspx page with a button onclick that opens an HTA page that simply runs javascript to open a client desktop application...the aspx form remains open. I would like to set...
1
by: Jan Van Steenbergen | last post by:
Hi all i'm having a little problem I have a aspx file with a iFrame defined The iframe is loaded with a html webeditor After editing data in the webeditor textbox, i want t get the data to a...
6
by: David Bowey | last post by:
Hi There! I'm writing a custom HttpHandler to create watermarks on my PNG images of my website. So typically, a PNG image is linked in an ASPX page as follows... <img src="images/test.png"...
1
by: Lyners | last post by:
What I need - To retrieve the server name that the ASP application is running on. Why - Our current intranet is on a network where we have users that are on a domain and some that are not. Using...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
4
by: ismailc | last post by:
Good day, Javscript server side needed to connect & retrieve from SQL DB. Can you please help by providing some code? I have an aspx page which I want to edit by adding information from a...
1
by: ismailc | last post by:
Good day, Need to connect & retrieve from SQL DB in aspx page. I don't know aspx & only want to edit the page to sow additional information. Can you please help by providing some code? ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
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...

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.