472,354 Members | 1,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Can this be done? Capture HTML rendered from an aspx page request into a string variable.

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 that (has the style
ZOOM: 50%;). This DIV tag with the injected HTML provides the user with a
"preview" of template. This is all works very well and good with raw HTML
files (that are the templates).

My question: When I move to templates that are ASPX files and not simple
HTML files, how can I provide the page preview as described above? The
current method of reading the HTML of the an ASPX file into the DIV tag
would not work - given that the ASPX file would first need to be processed.
Is there a way to make ASP.NET process an ASPX request and capture the
results into a string variable that I could then inject into the <DIV> tag?
Or would there be another/better/possible way? Here's specifically what I
think I need (and I'd like your input on steps 3 and 4 - I can do everything
else).

1. Provide use with list of icons representing templates.

2. When user clicks on an icon - fire a postback

During Postback:

3. Somehow have ASP.NET process the ASPX file that corresponds with the
template the user selected.

4. Capture the resulting HTML from step 3 into a string variable (rather
than rendering it to the client).

5. Inject the captured HTML from step 4 into the DIV tag.

Thanks you very very very much!!!
Nov 18 '05 #1
1 2461
Try using the Execute method of HttpServerUtility:

StringWriter writer = new StringWriter();
Server.Execute("otherpage.aspx", writer);
string text = writer.ToString();

HTH,

--
Scott
http://www.OdeToCode.com

On Fri, 2 Jul 2004 11:29:32 -0700, "Hose B" <A@B.com> wrote:
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 that (has the style
ZOOM: 50%;). This DIV tag with the injected HTML provides the user with a
"preview" of template. This is all works very well and good with raw HTML
files (that are the templates).

My question: When I move to templates that are ASPX files and not simple
HTML files, how can I provide the page preview as described above? The
current method of reading the HTML of the an ASPX file into the DIV tag
would not work - given that the ASPX file would first need to be processed.
Is there a way to make ASP.NET process an ASPX request and capture the
results into a string variable that I could then inject into the <DIV> tag?
Or would there be another/better/possible way? Here's specifically what I
think I need (and I'd like your input on steps 3 and 4 - I can do everything
else).

1. Provide use with list of icons representing templates.

2. When user clicks on an icon - fire a postback

During Postback:

3. Somehow have ASP.NET process the ASPX file that corresponds with the
template the user selected.

4. Capture the resulting HTML from step 3 into a string variable (rather
than rendering it to the client).

5. Inject the captured HTML from step 4 into the DIV tag.

Thanks you very very very much!!!


Nov 18 '05 #2

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

Similar topics

1
by: Robin Dindayal | last post by:
Does anyone know how I can print a fully rendered .aspx to the server's printer? I know that, if I wanted to print to the client's printer it would be easy (ie. use javascript's window.print()). ...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
2
by: Rob Venable | last post by:
Hi everyone, I'm migrating to .Net and in Classic ASP I build registration forms that submits to itself and calls different subroutines that contain HTML code based on which step they're on. This...
3
by: news | last post by:
I am trying to get at the source of a web page. Looking at the innerHTML element is only part of the story. In IE, right-clicking on various different parts of the page gives me different results...
4
by: orianavim | last post by:
Hi, I'm try to find an easy efficient way to generate my web pages dynamically from an xml/text file. What exactly I want? I want that whenever a pages is loaded it will go and read an...
6
by: André | last post by:
Hi, Not sure it's a asp.net problem, but i discovered it with asp.net, so ... I need to pass data from page to another, so i use cookies for that. My problem is that when a certain amount of...
1
by: mark4asp | last post by:
Ok so my previous message about the vanishing ReturnUrl value was also lost! - grrrr Fate - I'll get my revenge on you - if you think you can toy with me like this! I decided to change the form...
3
by: Smithers | last post by:
Just wondering what it would take to cache a copy of the output HTML from a dynamically constructed aspx page before it is sent to the browser. Reason being: the page is constructed of a few user...
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
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

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.