Response.write position

  • Thread starter Thread starter Gav
  • Start date Start date
G

Gav

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
 
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>

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...
 
Write your stuff out from your Render method rather than wherever you are
writing it now (probably Page_Load).
 
Hi Gav,

There are 2 ways of writing code to client side.
One is overriding Render method, the other is using
RegisterClientScriptBlock 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" <[email protected]>
| 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: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: pc2-grim3-3-cust103.nott.cable.ntl.com 81.99.145.103
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:181370
| X-Tomcat-NG: microsoft.public.dotnet.languages.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
|
|
|
 
Back
Top