response.write giving error

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,

I'm working on an application whose code was written by some other developer
and I dont completely understand its source code right now. In one of the
pages where I'm writing a test code, at the end of the Page_Load event I
write a simple following line:
if (IsPostBack)
{
Response.Write("say");
}

If I write this code, than this page gives the following error in a message
box:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received
from the server could not be parsed. Common causes for this error are when
the response is modified by calls to Response.Write(), response filters,
HttpModules, or server trace is enabled.

Details: Error parsing near 'say1415|updatePanel|'."

What does this mean and how can I fix this? In a normal new asp.net project
that I make and if I write the same code as above, this gets executed fine.

Regards,

...ab
 
Hi,

I'm working on an application whose code was written by some other developer
and I dont completely understand its source code right now. In one of the
pages where I'm writing a test code, at the end of the Page_Load event I
write a simple following line:
if (IsPostBack)
{
  Response.Write("say");

}

If I write this code, than this page gives the following error in a message
box:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received
from the server could not be parsed. Common causes for this error are when
the response is modified by calls to Response.Write(), response filters,
HttpModules, or server trace is enabled.

Details: Error parsing near 'say1415|updatePanel|'."

What does this mean and how can I fix this? In a normal new asp.net project
that I make and if I write the same code as above, this gets executed fine.

Regards,

..ab

Hi

I've not seen this before but I'm not altogether surprised that it has
arisen. Response.Write() sends raw characters to the output stream
which may or may not constitute coherent data when combined with the
rest of the page content.

If you wish to put raw text onto the page then use a Literal control.
 
If you wish to put raw text onto the page then use a Literal control.

I did use a Literal control but it was not showing up on that page, doesnt
exists if I view the source of the page and thats why I chose the
response.write.

I used the following code:

LiteralControl lc = new LiteralControl();
//lc.Text = "<script>alert('helllo')</script>";
//lc.Text = "<div>hello<br/>world</div>";
Controls.Add(lc);

I tried both of the commented lines and the litral control didnt show up.
But than I dragged one literal control from the toolbox and placed it inside
one of the controls/tables and than assigned its text property through code
and my text shows up there.

Hi,

I'm working on an application whose code was written by some other
developer
and I dont completely understand its source code right now. In one of the
pages where I'm writing a test code, at the end of the Page_Load event I
write a simple following line:
if (IsPostBack)
{
Response.Write("say");

}

If I write this code, than this page gives the following error in a
message
box:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received
from the server could not be parsed. Common causes for this error are when
the response is modified by calls to Response.Write(), response filters,
HttpModules, or server trace is enabled.

Details: Error parsing near 'say1415|updatePanel|'."

What does this mean and how can I fix this? In a normal new asp.net
project
that I make and if I write the same code as above, this gets executed
fine.

Regards,

..ab

Hi

I've not seen this before but I'm not altogether surprised that it has
arisen. Response.Write() sends raw characters to the output stream
which may or may not constitute coherent data when combined with the
rest of the page content.

If you wish to put raw text onto the page then use a Literal control.
 
I did use a Literal control but it was not showing up on that page, doesnt
exists if I view the source of the page and thats why I chose the
response.write.

I used the following code:

LiteralControl lc = new LiteralControl();
//lc.Text = "<script>alert('helllo')</script>";
//lc.Text = "<div>hello<br/>world</div>";
Controls.Add(lc);

I tried both of the commented lines and the litral control didnt show up.
But than I dragged one literal control from the toolbox and placed it inside
one of the controls/tables and than assigned its text property through code
and my text shows up there.








Hi

I've not seen this before but I'm not altogether surprised that it has
arisen. Response.Write() sends raw characters to the output stream
which may or may not constitute coherent data when combined with the
rest of the page content.

If you wish to put raw text onto the page then use a Literal control.- Hide quoted text -

- Show quoted text -

Hi Abubakar

Sorry it's been so long since you replied.

I don't think I made myself clear in suggesting a Literal control.

The control needs to be declarative, not created programmatically.

e.g.

page source:

<form id="Form1" runat="server">
<div>
....

<asp:literal ID="ALiteral" runat="server" ></asp:literal>

....

code behind:

ALiteral.text = "<p>Hello world</p>"

If as Patrice suggested you are using Ajax then I bow out due to lack
of experience.
 
Back
Top