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

Discussion in 'ASP .Net' started by Hose B, Jul 2, 2004.

  1. Hose B

    Hose B Guest

    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!!!
     
    Hose B, Jul 2, 2004
    #1
    1. Advertisements

  2. Hose B

    Scott Allen Guest

    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" <> 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!!!
    >
     
    Scott Allen, Jul 2, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robin Dindayal

    Print rendered .aspx page to server's printer

    Robin Dindayal, Jul 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    729
    Robin Dindayal
    Jul 25, 2003
  2. Christopher Ambler

    Re: loading a html page into a aspx page

    Christopher Ambler, Aug 28, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    1,330
    John Saunders
    Aug 28, 2003
  3. Jon Maz
    Replies:
    10
    Views:
    874
    Jon Maz
    Feb 11, 2004
  4. Stephen Miller
    Replies:
    5
    Views:
    9,938
    kaverao
    Sep 17, 2009
  5. Earl Teigrob
    Replies:
    6
    Views:
    8,173
    wadewalker25
    Sep 28, 2007
  6. Timo
    Replies:
    4
    Views:
    639
  7. Paul W
    Replies:
    2
    Views:
    10,387
    Alan Samet
    Jul 17, 2005
  8. uto
    Replies:
    1
    Views:
    548
    Spam Catcher
    Jan 26, 2006
Loading...