Render HTML text in the Response object

Discussion in 'ASP .Net' started by Paul Turley, Dec 13, 2003.

  1. Paul Turley

    Paul Turley Guest

    I have a string (or byte array) containing an entire page definition not
    contained in a file ("<htm><head>...</head><body>...</body></html>") that I
    need to render when the user clicks a button. Can I send this string to the
    Reponse object? This "page" is the response.

    FYI, this is the content returned by the SQL Reporting Services web service.

    --
    Paul Turley, MCSD, MCDBA, MCAD, MSF, MCT, Project+, A+
    paul@scout-master.(com - remove parentheses)
    www.scout-master.com
    Paul Turley, Dec 13, 2003
    #1
    1. Advertising

  2. Paul Turley

    Hermit Dave Guest

    Hi,
    Hope you are not making fun.

    If you have it as a string or a byte array and need to return it as the
    response.
    1. You will have to set Response.Buffer = true (so that no response is sent
    to the client)
    2. After you have the string or the byte array, do a Response.clear( ) to
    clear up any stuff
    3. Response.ContentType = "text/html"
    4. Response.Write(string)
    5. Response.fluch( )
    6. You can explicitly call Response.End to signal the end of response

    Chao for now,

    Hermit Dave

    "Paul Turley" <paul@createsolutions.(what you use to catch a butterfly)>
    wrote in message news:...
    > I have a string (or byte array) containing an entire page definition not
    > contained in a file ("<htm><head>...</head><body>...</body></html>") that

    I
    > need to render when the user clicks a button. Can I send this string to

    the
    > Reponse object? This "page" is the response.
    >
    > FYI, this is the content returned by the SQL Reporting Services web

    service.
    >
    > --
    > Paul Turley, MCSD, MCDBA, MCAD, MSF, MCT, Project+, A+
    > paul@scout-master.(com - remove parentheses)
    > www.scout-master.com
    >
    >
    Hermit Dave, Dec 13, 2003
    #2
    1. Advertising

  3. Paul Turley

    Hermit Dave Guest

    if you have the data in byte[], then use
    Response.BinaryWrite(yourDataByteArray)

    Regards,

    Hermit Dave

    "Paul Turley" <paul@createsolutions.(what you use to catch a butterfly)>
    wrote in message news:...
    > I have a string (or byte array) containing an entire page definition not
    > contained in a file ("<htm><head>...</head><body>...</body></html>") that

    I
    > need to render when the user clicks a button. Can I send this string to

    the
    > Reponse object? This "page" is the response.
    >
    > FYI, this is the content returned by the SQL Reporting Services web

    service.
    >
    > --
    > Paul Turley, MCSD, MCDBA, MCAD, MSF, MCT, Project+, A+
    > paul@scout-master.(com - remove parentheses)
    > www.scout-master.com
    >
    >
    Hermit Dave, Dec 13, 2003
    #3
  4. Paul Turley wrote:

    > I have a string (or byte array) containing an entire page definition not
    > contained in a file ("<htm><head>...</head><body>...</body></html>") that I
    > need to render when the user clicks a button. Can I send this string to the
    > Reponse object? This "page" is the response.
    >
    > FYI, this is the content returned by the SQL Reporting Services web service.
    >


    I find the simplest solution is to override the Render method/event of
    the page, and in there write out the string you have (and don't call
    your parent class's Render method). So you'll have to pry put the
    string in a pageclass-level variable to get it inside Render.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder, Dec 13, 2003
    #4
    1. Advertising

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. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,047
    Lau Lei Cheong
    May 15, 2004
  2. Damon Payne
    Replies:
    0
    Views:
    9,132
    Damon Payne
    Mar 8, 2005
  3. Jesús Bosch
    Replies:
    1
    Views:
    13,056
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 3, 2006
  4. Glenn Gillen
    Replies:
    0
    Views:
    262
    Glenn Gillen
    Nov 17, 2006
  5. Replies:
    1
    Views:
    309
    Martin Honnen
    Nov 20, 2007
Loading...

Share This Page