Response.write position

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gav

    #1

    Response.write position

    Hi all,

    I have created a user control and I am using Response.Write in the control
    to 'write' exactly what I want although it always goes to the top of the
    page (above <HTML><HEAD> etc). Can I get it so that it writes it where the
    control is on the page?

    ie

    <html>
    blah blah
    <body>
    <H1> my control </h1>
    <webusercontrol :mycontrol />
    <html>

    at the minute if I do repsonse.write( "test") in the user control it writes
    like this to the client:

    test
    <html>
    blah blah
    <body>
    blah blah
    <H1> my control </h1>
    <html>

    where as I would want it to put it where the control is:

    <html>
    blah blah
    <body>
    <H1> my control </h1>
    test
    <html>

    Thanks
    Gav


  • NULL

    #2
    Re: Response.write position

    On Mon, 1 Sep 2003 21:09:10 +0100, "Gav" <spam@spam.co m> wrote:
    [color=blue]
    >Hi all,
    >
    >I have created a user control and I am using Response.Write in the control
    >to 'write' exactly what I want although it always goes to the top of the
    >page (above <HTML><HEAD> etc). Can I get it so that it writes it where the
    >control is on the page?
    >
    >ie
    >
    ><html>
    >blah blah
    ><body>
    > <H1> my control </h1>
    > <webusercontrol :mycontrol />
    ><html>
    >
    >at the minute if I do repsonse.write( "test") in the user control it writes
    >like this to the client:
    >
    >test
    ><html>
    >blah blah
    ><body>
    > blah blah
    > <H1> my control </h1>
    ><html>
    >
    >where as I would want it to put it where the control is:
    >
    ><html>
    >blah blah
    ><body>
    > <H1> my control </h1>
    > test
    ><html>[/color]

    I'm afraid the results of response.write are returned to the client
    _before_ the result of your aspx-page (the HTML generated for your
    aspx-page)...

    However, I would like to see my statement confirmed...

    --
    NULL

    Comment

    • Justin Rogers

      #3
      Re: Response.write position

      Write your stuff out from your Render method rather than wherever you are
      writing it now (probably Page_Load).


      --
      Justin Rogers
      DigiTec Web Consultants, LLC.

      "Gav" <spam@spam.co m> wrote in message
      news:uOQlvTMcDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
      > Hi all,
      >
      > I have created a user control and I am using Response.Write in the control
      > to 'write' exactly what I want although it always goes to the top of the
      > page (above <HTML><HEAD> etc). Can I get it so that it writes it where the
      > control is on the page?
      >
      > ie
      >
      > <html>
      > blah blah
      > <body>
      > <H1> my control </h1>
      > <webusercontrol :mycontrol />
      > <html>
      >
      > at the minute if I do repsonse.write( "test") in the user control it writes
      > like this to the client:
      >
      > test
      > <html>
      > blah blah
      > <body>
      > blah blah
      > <H1> my control </h1>
      > <html>
      >
      > where as I would want it to put it where the control is:
      >
      > <html>
      > blah blah
      > <body>
      > <H1> my control </h1>
      > test
      > <html>
      >
      > Thanks
      > Gav
      >
      >[/color]


      Comment

      • Jeffrey Tan[MSFT]

        #4
        RE: Response.write position


        Hi Gav,

        There are 2 ways of writing code to client side.
        One is overriding Render method, the other is using
        RegisterClientS criptBlock method.

        I think you can override the render method of the user control and
        write your string to HtmlTextWrite.

        Hope this helps.

        Best regards,
        Jeffrey Tan
        Microsoft Online Partner Support
        Get Secure! - www.microsoft.com/security
        This posting is provided "as is" with no warranties and confers no rights.

        --------------------
        | From: "Gav" <spam@spam.co m>
        | Subject: Response.write position
        | Date: Mon, 1 Sep 2003 21:09:10 +0100
        | Lines: 40
        | X-Priority: 3
        | X-MSMail-Priority: Normal
        | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
        | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
        | Message-ID: <uOQlvTMcDHA.29 32@tk2msftngp13 .phx.gbl>
        | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | NNTP-Posting-Host: pc2-grim3-3-cust103.nott.ca ble.ntl.com 81.99.145.103
        | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
        | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1813 70
        | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        |
        | Hi all,
        |
        | I have created a user control and I am using Response.Write in the control
        | to 'write' exactly what I want although it always goes to the top of the
        | page (above <HTML><HEAD> etc). Can I get it so that it writes it where the
        | control is on the page?
        |
        | ie
        |
        | <html>
        | blah blah
        | <body>
        | <H1> my control </h1>
        | <webusercontrol :mycontrol />
        | <html>
        |
        | at the minute if I do repsonse.write( "test") in the user control it writes
        | like this to the client:
        |
        | test
        | <html>
        | blah blah
        | <body>
        | blah blah
        | <H1> my control </h1>
        | <html>
        |
        | where as I would want it to put it where the control is:
        |
        | <html>
        | blah blah
        | <body>
        | <H1> my control </h1>
        | test
        | <html>
        |
        | Thanks
        | Gav
        |
        |
        |

        Comment

        Working...