ryoung
ryoung

Reputation: 846

ASP .NET Ajax UpdatePanel Sys.WebForms.PageRequestManagerParserErrorException

I have searched, and searched, .. and searched. I have seen many posts here and on other forums regarding a similar issue. However, none of them seem to be helping. I have posted the relating asp and vb code below (please forgive me for the vb it wasn't my choice). If you look at the vb code you will notice that I am building a link "

"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 '7.180/test/Members/Widget/bob'>leader de'."

<asp:UpdatePanel ID="updatePanel" runat="server">
        <Triggers><asp:AsyncPostBackTrigger ControlID="searchBtn" EventName="Click" /></Triggers>
        <ContentTemplate>
            <asp:HiddenField ID="focusTab" runat="server" Value="" />
            <div id="tabs" class="tabsContainer">
                <ul>
                    <li id="c2Link"><a href="#c2Tab">bill</a></li>
                    <li id="intelLink"><a href="#intelTab">bob</a></li>
                    <li id="manLink"><a href="#manTab">man</a></li>
                    <li id="firesLink"><a href="#firesTab">fire</a></li>
                    <li id="protLink"><a href="#protTab">joe</a></li>
                    <li id="sustLink"><a href="#sustTab">jill</a></li>
                </ul>                
                <div id="c2Tab" class="panel">
                    <asp:Label ID="c2Results" runat="server" Text="No results found in this category."></asp:Label>
                </div>
                <div id="intelTab" class="panel">
                    <asp:Label ID="intelResults" runat="server" Text="No results found in this category."></asp:Label>
                </div>
                <div id="manTab" class="panel">
                    <asp:Label ID="manResults" runat="server" Text="No results found in this category."></asp:Label>
                </div>
                <div id="firesTab" class="panel">
                    <asp:Label ID="firesResults" runat="server" Text="No results found in this category."></asp:Label>
                </div>
                <div id="protTab" class="panel">
                    <asp:Label ID="protResults" runat="server" Text="No results found in this category."></asp:Label>
                </div>
                <div id="sustTab" class="panel">
                    <asp:Label ID="sustResults" runat="server" Text="No results found in this category."></asp:Label>
                </div>   
            </div>
        </ContentTemplate>
   </asp:UpdatePanel>

   <span class="kwSearchHdr">Search (seperate keywords w/comma)</span>
   <asp:TextBox ID="kwSearchTxt" runat="server" CssClass="kwSearchBx"/>  

   <span class="dateHdr">From/To Date</span>           
   <asp:TextBox ID="fromDateTxt" runat="server" CssClass="fromDate"/>
   <asp:TextBox ID="toDateTxt" runat="server" CssClass="toDate"/>

   <asp:Button ID="searchBtn" runat="server" Text="Search" CssClass="searchBtn"/>

VB Code: The returned string as appended to a one of the labels

Private Function buildResultStr(ByVal result As AdvisorInsightView) As String
    Dim resultsStr As String = ""
    Dim baseUrl As String = "./WidgetViewInsight.aspx?Insight={0}"
    Dim text As New TextFunctions
    Dim snippet As String = ""
    Dim member As New JCISFAMember(Convert.ToInt16(result.Author))

    resultsStr += "<p>- <a href='"
    'resultsStr += Page.ResolveUrl(String.Format(baseUrl, result.InsightID))
    resultsStr += "' style='font-size:11;' >"
    resultsStr += result.Subject & "</a>, "
    resultsStr += Convert.ToDateTime(result.PubDate).ToShortDateString() & ", "
    resultsStr += member.GetAuthorDetails() & "<br />"

    snippet = text.stripRichTextFormatting(result.Observation)

    If snippet.Length > MAX_SNIP_LEN Then
        snippet = snippet.Substring(0, MAX_SNIP_LEN) & "..."
    End If

    resultsStr += snippet & "<br />"
    resultsStr += "<b>Keywords: </b>"

    If result.Keywords.Equals("") Then
        resultsStr += "None.</p>"
    Else
        resultsStr += "<span class='keywords'>"
        Dim keywords As String() = Split(result.Keywords, ", ")
        Dim keywordStr As String = ""
        Dim charCount As Integer = 0

        For i As Integer = 0 To keywords.Length - 1
            If charCount + keywords(i).Length >= 75 Then
                keywordStr += "..."
                Exit For
            End If
            Dim url As String = "bob" ' "./SearchResults.aspx?CategoryID=" & keywords(i)
            keywordStr += "<a href='" & url & "'>" & keywords(i) & "</a>"

            If i <> keywords.Length - 1 Then
                keywordStr += ", "
            End If
            charCount += keywords(i).Length
        Next

        resultsStr += keywordStr & "</span></p>"
    End If

    Return resultsStr
End Function

Upvotes: 1

Views: 2667

Answers (2)

ryoung
ryoung

Reputation: 846

It turns out the problem was that I was inserting a partial url or path (e.g. href="./WebPage.aspx"). This causes the browser to fill in the rest of the url which is done by writing out to the response and therefore causes the issue here. I.E. in order to solve this problem I have to build a full uri to put in the href field on server side in order to stop and writes to the response.

Upvotes: 1

Nikhil
Nikhil

Reputation: 3384

This is a short in the dark but I have had this problem with a custom control I was using. Try adding this to your code behind (form load) and see if this makes a difference

Page.Form.Method = "post";
        Page.Form.Enctype = "multipart/form-data";

Upvotes: 0

Related Questions