Ajax error when using response.write()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim in Arizona

    Ajax error when using response.write()

    I'm brand new at ajax. In fact, about 20 minutes ago was the first time I
    got it to work. The problem I'm having on another page did not work,
    however.

    I'm running into the following error:

    Sys.WebForms.Pa geRequestManage rParserErrorExc eption: 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 'greengreengree ngreen'.


    This is my code. The strBorder variables is filled with an RGB color string
    from the code behind page, ie, the color Green (as noted in the error
    message I guess). I'm basically changing the color of a text box border
    based on what is being returned from the database. Its a system status
    message so if things are going wrong, a little red stop light is loaded next
    to the message and the border around the message changes to red.


    <asp:ScriptMana ger ID="ScriptManag er1" runat="server">
    </asp:ScriptManag er>

    <asp:UpdatePane l ID="UpdatePanel 1" runat="server">
    <ContentTemplat e>
    <asp:Timer ID="Timer1" runat="server" Interval="15000 "
    Enabled="true" OnTick="Timer1_ Tick" />

    <asp:DataList ID="dlSystemSta tus" runat="server" RepeatColumns=" 1"
    Width="100%">
    <ItemTemplate >

    <div style="border-bottom: 4px;
    border-left: 4px;
    border-right: 4px;
    border-top: 4x;
    border-bottom-style: double;
    border-left-style: double;
    border-right-style: double;
    border-top-style: double;
    border-bottom-color: <%Response.Writ e(strBorder) %>;
    border-left-color: <%Response.Writ e(strBorder) %>;
    border-right-color: <%Response.Writ e(strBorder) %>;
    border-top-color: <%Response.Writ e(strBorder) %>;
    background-color: White;
    margin-right: 5%;
    padding:5px;
    font-family:Tahoma;f ont-size:10pt;">

    <table border="0" cellpadding="0" cellspacing="0" >
    <tr>
    <td valign="top" style="width:40 px;"><img
    src="<%Response .Write(strLight )%>" align="absmiddl e" /></td>
    <td valign="top">
    <i>Posted By <%# Eval("originato r") %>, <%#Eval("jobdes c")%on <%#
    Eval("date") %at <%#Eval("time") %></i>
    <hr size="2" color="black"/>
    <b>Customer Message</b>
    <br />
    <%# Eval("message") %>
    <hr />
    <b>Technical Details</b>
    <br />
    <%#Eval("techni cal")%>
    </td>
    </tr>
    </table>

    </div>

    </ItemTemplate>
    </asp:DataList>

    </ContentTemplate >
    </asp:UpdatePanel >

    If AJAX can't handel the Response.Write within the update panel, is there
    another way to go about this?

    TIA,
    Jim


  • Mark Stevens

    #2
    Re: Ajax error when using response.write( )

    On Tue, 6 May 2008 11:08:04 -0700, "Jim in Arizona"
    <tiltowait@hotm ail.comwrote:
    <div style="border-bottom: 4px;
    Have you thought about using and ASP Panel here and setting the colour
    on the server?
    <td valign="top" style="width:40 px;"><img
    >src="<%Respons e.Write(strLigh t)%>" align="absmiddl e" /></td>
    Similarly, use an ASP Image control for the image and Labels for the
    messages.
    >If AJAX can't handel the Response.Write within the update panel, is there
    >another way to go about this?
    Regards,
    Mark
    --
    |\ _,,,---,,_ A picture used to be worth a
    ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
    |,4- ) )-,_. ,\ ( `'-' came television!
    '---''(_/--' `-'\_)

    Mark Stevens (mark at thepcsite fullstop co fullstop uk)

    This message is provided "as is".

    Comment

    • Lucid

      #3
      Re: Ajax error when using response.write( )

      Not sure if this is the same problem I had a bit ago, but if you have trace
      turned on for the page, Ajax goes insane about it.


      "Jim in Arizona" <tiltowait@hotm ail.comwrote in message
      news:eYhKjQ6rIH A.4476@TK2MSFTN GP06.phx.gbl...
      I'm brand new at ajax. In fact, about 20 minutes ago was the first time I
      got it to work. The problem I'm having on another page did not work,
      however.
      >
      I'm running into the following error:
      >
      Sys.WebForms.Pa geRequestManage rParserErrorExc eption: 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 'greengreengree ngreen'.
      >
      >
      This is my code. The strBorder variables is filled with an RGB color
      string from the code behind page, ie, the color Green (as noted in the
      error message I guess). I'm basically changing the color of a text box
      border based on what is being returned from the database. Its a system
      status message so if things are going wrong, a little red stop light is
      loaded next to the message and the border around the message changes to
      red.
      >
      >
      <asp:ScriptMana ger ID="ScriptManag er1" runat="server">
      </asp:ScriptManag er>
      >
      <asp:UpdatePane l ID="UpdatePanel 1" runat="server">
      <ContentTemplat e>
      <asp:Timer ID="Timer1" runat="server" Interval="15000 "
      Enabled="true" OnTick="Timer1_ Tick" />
      >
      <asp:DataList ID="dlSystemSta tus" runat="server" RepeatColumns=" 1"
      Width="100%">
      <ItemTemplate >
      >
      <div style="border-bottom: 4px;
      border-left: 4px;
      border-right: 4px;
      border-top: 4x;
      border-bottom-style: double;
      border-left-style: double;
      border-right-style: double;
      border-top-style: double;
      border-bottom-color: <%Response.Writ e(strBorder) %>;
      border-left-color: <%Response.Writ e(strBorder) %>;
      border-right-color: <%Response.Writ e(strBorder) %>;
      border-top-color: <%Response.Writ e(strBorder) %>;
      background-color: White;
      margin-right: 5%;
      padding:5px;
      font-family:Tahoma;f ont-size:10pt;">
      >
      <table border="0" cellpadding="0" cellspacing="0" >
      <tr>
      <td valign="top" style="width:40 px;"><img
      src="<%Response .Write(strLight )%>" align="absmiddl e" /></td>
      <td valign="top">
      <i>Posted By <%# Eval("originato r") %>, <%#Eval("jobdes c")%on <%#
      Eval("date") %at <%#Eval("time") %></i>
      <hr size="2" color="black"/>
      <b>Customer Message</b>
      <br />
      <%# Eval("message") %>
      <hr />
      <b>Technical Details</b>
      <br />
      <%#Eval("techni cal")%>
      </td>
      </tr>
      </table>
      >
      </div>
      >
      </ItemTemplate>
      </asp:DataList>
      >
      </ContentTemplate >
      </asp:UpdatePanel >
      >
      If AJAX can't handel the Response.Write within the update panel, is there
      another way to go about this?
      >
      TIA,
      Jim
      >

      Comment

      • Jim in Arizona

        #4
        Re: Ajax error when using response.write( )


        "Mark Stevens" <nevyn@nospam.n ospamwrote in message
        news:5ja124l291 6u4vc4es4cgr5q7 qgef7n1vr@4ax.c om...
        On Tue, 6 May 2008 11:08:04 -0700, "Jim in Arizona"
        <tiltowait@hotm ail.comwrote:
        >
        ><div style="border-bottom: 4px;
        >
        Have you thought about using and ASP Panel here and setting the colour
        on the server?
        >
        ><td valign="top" style="width:40 px;"><img
        >>src="<%Respon se.Write(strLig ht)%>" align="absmiddl e" /></td>
        >
        Similarly, use an ASP Image control for the image and Labels for the
        messages.
        >
        >>If AJAX can't handel the Response.Write within the update panel, is there
        >>another way to go about this?
        >
        Regards,
        Mark
        --
        |\ _,,,---,,_ A picture used to be worth a
        ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
        |,4- ) )-,_. ,\ ( `'-' came television!
        '---''(_/--' `-'\_)
        >
        Mark Stevens (mark at thepcsite fullstop co fullstop uk)
        >
        This message is provided "as is".


        I started to do what you suggested but ran into some problems.
        I'm not all that good with asp.net so I do run into some frustrations from
        time to time.

        The problem here is that I'm using a datalist. Any asp:controls that I place
        within the <asp:datalist.. element on the aspx page are not recognized when
        I try to utilize them in the code behind.

        This is a basic datalist object and I am not using any of its 'commands'. In
        the past when I had used them, the sub looked like this:

        Sub UpdateRequest(B yVal sender As Object, ByVal e As
        DataListCommand EventArgs)

        The datalistcommand eventargs object allowed me to 'find' the asp item within
        the aspx page by doing something like this:

        Dim imgSignalLight As New Image
        imgSignalLight = e.Item.FindCont rol("imgSignalL ight")

        Then I could manipulate the object.

        I can't seem to find any other way to fix my current problem. IN my code
        behind page, I have a simple sub procedure (method as you C# people like to
        call them) that does the database connection and SQL query to fill the
        dataset that populates the datalist located on the aspx page. I can't just
        at 'e As DataListCommand EventArgs' as a part of the procedure. I tried to
        create a DataListCommand EventArgs object within the connection sub routine
        but it asked for things I didn't know, ie:

        Dim e As DataListCommand EventArgs(item as DataList, commandSource as Object,
        originalArgs as CommandEventArg s)

        the datalist would be the name of my datalist, I'm assuming, but I can't
        figure out what the other objects would be or where they would come from.

        So, the point is, is that I can't use any asp.net controls within a datalist
        UNLESS they are part of the datalist's standard events, like UpdateCommand,
        DeleteCommand, and so on, where I could then reference the objects using the
        DataListCommand EventArgs class stated as a paramater within one of these
        'Command' events. All I need to do is figure out how to make my own
        procedure (method) that works like the Command events that are part of the
        datalist control. I actually tried that but then I don't know how to call
        the procedure properly, ie:
        Sub SystemStatus()
        db connection code here
        End Sub

        into

        Sub SystemStatus(By Val sender As Object, ByVal e As
        DataListCommand EventArgs)
        ....db connection and query code...
        Dim imgSignal as Image
        imgSignal = e.Item.FindCont rol("imgSignal" )
        End Sub

        Then, how would I call that sub, say, within the Page_Load routine (or ajax
        timer routine)? What would be the 'sender' object that would be a required
        paramater, for instance?


        Comment

        • Jim in Arizona

          #5
          Re: Ajax error when using response.write( )


          "Lucid" <lucid@phreak20 00.comwrote in message
          news:FBAF1811-BFC4-4E2A-92A4-DA418AC0D566@mi crosoft.com...
          Not sure if this is the same problem I had a bit ago, but if you have
          trace turned on for the page, Ajax goes insane about it.
          >

          Well, its worth a try rather than trying to redo all my code.
          Is tracing turned on by default because I didn't take any action to turn it
          on.
          How do you turn it off?

          Thanks Lucid.


          Comment

          • Lucid

            #6
            Re: Ajax error when using response.write( )

            Hrm, if you didnt turn it on yourself its more than likely not on, but if
            you want to check look at the source of the offending page up at the top it
            will have trace="true".


            "Jim in Arizona" <tiltowait@hotm ail.comwrote in message
            news:O5FXJp7rIH A.4260@TK2MSFTN GP05.phx.gbl...
            >
            "Lucid" <lucid@phreak20 00.comwrote in message
            news:FBAF1811-BFC4-4E2A-92A4-DA418AC0D566@mi crosoft.com...
            >Not sure if this is the same problem I had a bit ago, but if you have
            >trace turned on for the page, Ajax goes insane about it.
            >>
            >
            >
            Well, its worth a try rather than trying to redo all my code.
            Is tracing turned on by default because I didn't take any action to turn
            it on.
            How do you turn it off?
            >
            Thanks Lucid.
            >

            Comment

            • bruce barker

              #7
              Re: Ajax error when using response.write( )

              instead of response.write, try: <%=strBorder% >


              Jim in Arizona wrote:
              I'm brand new at ajax. In fact, about 20 minutes ago was the first time I
              got it to work. The problem I'm having on another page did not work,
              however.
              >
              I'm running into the following error:
              >
              Sys.WebForms.Pa geRequestManage rParserErrorExc eption: 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 'greengreengree ngreen'.
              >
              >
              This is my code. The strBorder variables is filled with an RGB color string
              from the code behind page, ie, the color Green (as noted in the error
              message I guess). I'm basically changing the color of a text box border
              based on what is being returned from the database. Its a system status
              message so if things are going wrong, a little red stop light is loaded next
              to the message and the border around the message changes to red.
              >
              >
              <asp:ScriptMana ger ID="ScriptManag er1" runat="server">
              </asp:ScriptManag er>
              >
              <asp:UpdatePane l ID="UpdatePanel 1" runat="server">
              <ContentTemplat e>
              <asp:Timer ID="Timer1" runat="server" Interval="15000 "
              Enabled="true" OnTick="Timer1_ Tick" />
              >
              <asp:DataList ID="dlSystemSta tus" runat="server" RepeatColumns=" 1"
              Width="100%">
              <ItemTemplate >
              >
              <div style="border-bottom: 4px;
              border-left: 4px;
              border-right: 4px;
              border-top: 4x;
              border-bottom-style: double;
              border-left-style: double;
              border-right-style: double;
              border-top-style: double;
              border-bottom-color: <%Response.Writ e(strBorder) %>;
              border-left-color: <%Response.Writ e(strBorder) %>;
              border-right-color: <%Response.Writ e(strBorder) %>;
              border-top-color: <%Response.Writ e(strBorder) %>;
              background-color: White;
              margin-right: 5%;
              padding:5px;
              font-family:Tahoma;f ont-size:10pt;">
              >
              <table border="0" cellpadding="0" cellspacing="0" >
              <tr>
              <td valign="top" style="width:40 px;"><img
              src="<%Response .Write(strLight )%>" align="absmiddl e" /></td>
              <td valign="top">
              <i>Posted By <%# Eval("originato r") %>, <%#Eval("jobdes c")%on <%#
              Eval("date") %at <%#Eval("time") %></i>
              <hr size="2" color="black"/>
              <b>Customer Message</b>
              <br />
              <%# Eval("message") %>
              <hr />
              <b>Technical Details</b>
              <br />
              <%#Eval("techni cal")%>
              </td>
              </tr>
              </table>
              >
              </div>
              >
              </ItemTemplate>
              </asp:DataList>
              >
              </ContentTemplate >
              </asp:UpdatePanel >
              >
              If AJAX can't handel the Response.Write within the update panel, is there
              another way to go about this?
              >
              TIA,
              Jim
              >
              >

              Comment

              • Jim in Arizona

                #8
                Re: Ajax error when using response.write( ) [RESOLVED]

                Well damn Bruce! I think you just saved me a lot of time and frustration!
                Thanks!
                It's often something small, isn't it?


                "bruce barker" <nospam@nospam. comwrote in message
                news:eAXT0H%23r IHA.1316@TK2MSF TNGP06.phx.gbl. ..
                instead of response.write, try: <%=strBorder% >

                Comment

                Working...