response.write on postback

Discussion in 'ASP .Net' started by Jason Hartsoe, Sep 24, 2008.

  1. I get the error:
    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...when i postback to the
    page. The problem is, i need to write some dynamic javascript on postback
    and make sure it's rendered to the page.

    I'm setting up Omniture analytics for my site,

    <script language="JavaScript" type="text/javascript"><!--
    s.pageName = "Home"
    s.channel = "Home"
    s.hier1 = "Home"
    s.prop1="Something Dynamic Should Go Here"
    var s_code = s.t(); if (s_code) document.write(s_code)//--></script>

    I product an array of products to fill the "s.prop" variables. How can I
    get them from the codebehind, to the s.prop1="something, s.prop2="something
    more" and so on. Is there anyway to write from codebehind into the place
    where s.prop starts? I tried response.write...but it fails after postback.

    Thanks!
    Jason Hartsoe, Sep 24, 2008
    #1
    1. Advertising

  2. i forgot to mention it's inside an update panel...so if I could retrieve the
    variables from codebehind...i would.

    "Jason Hartsoe" wrote:

    > I get the error:
    > 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...when i postback to the
    > page. The problem is, i need to write some dynamic javascript on postback
    > and make sure it's rendered to the page.
    >
    > I'm setting up Omniture analytics for my site,
    >
    > <script language="JavaScript" type="text/javascript"><!--
    > s.pageName = "Home"
    > s.channel = "Home"
    > s.hier1 = "Home"
    > s.prop1="Something Dynamic Should Go Here"
    > var s_code = s.t(); if (s_code) document.write(s_code)//--></script>
    >
    > I product an array of products to fill the "s.prop" variables. How can I
    > get them from the codebehind, to the s.prop1="something, s.prop2="something
    > more" and so on. Is there anyway to write from codebehind into the place
    > where s.prop starts? I tried response.write...but it fails after postback.
    >
    > Thanks!
    Jason Hartsoe, Sep 24, 2008
    #2
    1. Advertising

  3. Jason Hartsoe

    bruce barker Guest

    response.write can not be used with update panels. nor can the panel have
    inline javascript. as the update panel works by setting the innerHTML of its
    div, any javascript blocks in html fragment are ignored by the browser. to
    send new script with an update panel you must use the ajax scriptmanger (not
    the asp.net one) and it client script register routines. scriptmanger sends
    the javascript in a seperate part of the payload, and client side ajax code
    parses it and adds it to the dom.

    -- bruce (sqlwork.com)


    "Jason Hartsoe" wrote:

    > I get the error:
    > 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...when i postback to the
    > page. The problem is, i need to write some dynamic javascript on postback
    > and make sure it's rendered to the page.
    >
    > I'm setting up Omniture analytics for my site,
    >
    > <script language="JavaScript" type="text/javascript"><!--
    > s.pageName = "Home"
    > s.channel = "Home"
    > s.hier1 = "Home"
    > s.prop1="Something Dynamic Should Go Here"
    > var s_code = s.t(); if (s_code) document.write(s_code)//--></script>
    >
    > I product an array of products to fill the "s.prop" variables. How can I
    > get them from the codebehind, to the s.prop1="something, s.prop2="something
    > more" and so on. Is there anyway to write from codebehind into the place
    > where s.prop starts? I tried response.write...but it fails after postback.
    >
    > Thanks!
    bruce barker, Sep 25, 2008
    #3
  4. i thought that may be the case...but how can I add dynamic variables to the
    javascript on postback? I'm reading a DB, throwing them into an array, then
    i need to output them to the javascript block....is that possible?

    "bruce barker" wrote:

    > response.write can not be used with update panels. nor can the panel have
    > inline javascript. as the update panel works by setting the innerHTML of its
    > div, any javascript blocks in html fragment are ignored by the browser. to
    > send new script with an update panel you must use the ajax scriptmanger (not
    > the asp.net one) and it client script register routines. scriptmanger sends
    > the javascript in a seperate part of the payload, and client side ajax code
    > parses it and adds it to the dom.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Jason Hartsoe" wrote:
    >
    > > I get the error:
    > > 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...when i postback to the
    > > page. The problem is, i need to write some dynamic javascript on postback
    > > and make sure it's rendered to the page.
    > >
    > > I'm setting up Omniture analytics for my site,
    > >
    > > <script language="JavaScript" type="text/javascript"><!--
    > > s.pageName = "Home"
    > > s.channel = "Home"
    > > s.hier1 = "Home"
    > > s.prop1="Something Dynamic Should Go Here"
    > > var s_code = s.t(); if (s_code) document.write(s_code)//--></script>
    > >
    > > I product an array of products to fill the "s.prop" variables. How can I
    > > get them from the codebehind, to the s.prop1="something, s.prop2="something
    > > more" and so on. Is there anyway to write from codebehind into the place
    > > where s.prop starts? I tried response.write...but it fails after postback.
    > >
    > > Thanks!
    Jason Hartsoe, Sep 25, 2008
    #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. Charles A. Lackman
    Replies:
    2
    Views:
    7,972
    Charles A. Lackman
    Jan 11, 2006
  2. Matthew Wieder

    Response.Write and Response.Redirect

    Matthew Wieder, Jul 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    675
    Kevin Spencer
    Jul 17, 2003
  3. Sehboo
    Replies:
    3
    Views:
    8,762
    Sehboo
    Dec 10, 2003
  4. Replies:
    1
    Views:
    819
  5. slawekg

    Response.Write and Response.Redirect

    slawekg, Jun 21, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    365
    Alexey Smirnov
    Jun 21, 2007
Loading...

Share This Page