This is a migrated thread and some comments may be shown as answers.

Trouble with RADAjaxManager

11 Answers 581 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 04 Mar 2008, 09:49 PM
I am trying to use RADAjaxManager but when I run my app and cause a trigger, I get the following error:

Microsoft JScript runtime 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(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'Manager1"));
});
|<div id="__asptrace"'.

The error is occuring in this code:

    function Sys$WebForms$PageRequestManager$_endPostBack(error, response) {  
        // DevDiv Bugs 130268: There could have been a 2nd request that started while this one was being  
        // processed. Detect this by comparing the request for the current response to the _request field,  
        // which stores the latest request that has begun. If they are different, do not clear the state  
        // data that will be required by the 2nd request's response.  
        if (this._request === response.get_webRequest()) {  
            this._processingRequest = false;  
            this._additionalInput = null;  
            this._request = null;  
        }  
 
        var handler = this._get_eventHandlerList().getHandler("endRequest");  
        var errorHandled = false;  
        if (handler) {  
            var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, this._dataItems, response);  
            handler(this, eventArgs);  
            errorHandled = eventArgs.get_errorHandled();  
        }  
        // DevDiv Bugs 130268: See above  
        if (!this._processingRequest) {  
            this._dataItems = null;  
        }  
        if (error && !errorHandled) {  
            // DevDiv 89485: throw, don't alert()  
            throw error;  
        }  
    }  
 

Here is my code:

        <form id="form1" runat="server">  
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
            </telerik:RadScriptManager> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"   
                EnableHistory="True">  
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="btnSearch">  
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="InputAgent" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
 

                <asp:FormView   
                    ID="InputAgent"   
                    Height="250px" Width="926px"   
                    DefaultMode="Edit"   
                    DataKeyNames="ID,Version"   
                    DataSourceID="srcAgent" 
                    AllowPaging="true" 
                  PagerSettings-Visible="false" 
                    OnItemUpdated="frmAgent_ItemUpdated" 
                    runat="server" HorizontalAlign="Left" 
                    > 
 
I have left out the Template code for the formview control.

What am I doing wrong?

11 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 05 Mar 2008, 01:05 PM
Hello Alan,

Could you provide more details about your case. For example what you are doing in code behind?
Any additional information will help us to pinpoint where the error comes from.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Alan
Top achievements
Rank 1
answered on 05 Mar 2008, 02:07 PM
Here is the code behind for the form:

Option Infer On  
Imports System.Linq  
Imports System.Data.Linq  
Imports System.Web.UI.WebControls  
Imports System.Web.UI  
Imports Telerik.Web.UI  
Imports BasePageVB  
 
Partial Class InputAgentForm  
    Inherits BasePage  
 
    Public Shared Function GetPostBackControl(ByVal Page As Page) As Control  
        Dim ctrl As Control = Nothing 
 
        Dim ctrlName As String = Page.Request.Params.Get("__EVENTTARGET")  
        If ctrlName <> "" Then  
            ctrl = Page.FindControl(ctrlName)  
        Else  
            For Each ctl In Page.Request.Form  
                Dim c As Control = Page.FindControl(ctl)  
                If TypeOf (c) Is Button Then  
                    cctrl = c  
                    Exit For  
                End If  
            Next  
        End If  
        Return ctrl  
    End Function  
 
    Private Sub page_Load(ByVal sender As System.Object, _  
    ByVal e As System.EventArgs) _  
    Handles MyBase.Load, Me.Load  
 
        Dim newCookie As HttpCookie  
        Dim SessionID As String  
 
        Try  
            If Request.Cookies("RentAPlace")("ServerName") <> "" Then  
                SessionID = Request.Cookies("RentAPlace")("SessionID")  
            End If  
        Catch ex As Exception  
            newCookie = New HttpCookie("RentAPlace")  
            newCookie.Values.Add("ServerName", "NewDellDeskTop\SQL2000")  
            newCookie.Values.Add("DBName", "RentalV3")  
            newCookie.Values.Add("SessionID", System.Guid.NewGuid().ToString())  
            newCookie.Values.Add("SingleUserQB", "True")  
            newCookie.Values.Add("DisabledQB", "True")  
            Response.Cookies.Add(newCookie)  
        End Try  
 
        If Not Page.IsPostBack Then  
            Session("ShowHiddenAgents") = 0  
            'Page.DataBind()  
            Session("InputAgentPage") = 1  
        End If  
 
    End Sub  
 
    Private Sub Search_Click( _  
     ByVal sender As System.Object, _  
     ByVal e As System.EventArgs) _  
     Handles btnSearch.Click  
 
        FindDynamic(0, 0)  
    End Sub  
 
    Private Sub SearchNext_Click( _  
     ByVal sender As System.Object, _  
     ByVal e As System.EventArgs) _  
     Handles btnSearchNext.Click  
 
        FindDynamic(InputAgent.PageIndex + 1, 0)  
    End Sub  
 
    Private Sub ShowHiddenPB_Click( _  
     ByVal sender As System.Object, _  
     ByVal e As System.EventArgs) _  
     Handles btnShowHidden.Click  
 
        Dim ShowHidden As Integer = Session("ShowHidden")  
 
        'Toggle session value ShowHidden  
        If ShowHidden = 1 Then  
            Session("ShowHidden") = 0  
            'btnShowHidden.Text = "Show Hidden" 
        Else  
            Session("ShowHidden") = 1  
            'btnShowHidden.Text = "Don't" & vbCrLf & "Show Hidden"  
        End If  
 
        Dim txt As TextBox = InputAgent.FindControl("tbxID")  
        Dim intID As Integer = Convert.ToInt32(txt.Text)  
 
        Session("AgentFindID") = intID  
        Session("AgentCurrentIndex") = InputAgent.PageIndex  
 
        Page.DataBind()  
        'FindDynamic(Convert.ToInt32(ID.Text), InputAgent.PageIndex + 1)  
    End Sub  
 
    Private Sub ShowHiddenPB_PreRend( _  
     ByVal sender As System.Object, _  
     ByVal e As System.EventArgs) _  
     Handles btnShowHidden.PreRender  
 
        'Make the button text agree with the Show Hidden session value  
        Dim ShowHidden As Integer = Session("ShowHidden")  
 
        'Toggle session value ShowHidden  
        If ShowHidden = 0 Then  
            btnShowHidden.Text = "Show Hidden" 
        Else  
            btnShowHidden.Text = "Don't" & vbCrLf & "Show Hidden"  
        End If  
 
        Dim c As Control = GetPostBackControl(Me.Page)  
        If Not c Is Nothing Then  
            If c.ID = "btnShowHidden" Then  
                Dim intCurrentID = Session("AgentFindID")  
                FindDynamic(0, intCurrentID)  
            End If  
        End If  
    End Sub  
 
    Sub FindDynamic( _  
    ByVal intStartIndex As Integer, _  
    ByVal intID As Integer _  
    )  
 
        Dim db As New RentalDBDataContext()  
        Dim ShowHidden As Integer = Session("ShowHidden")  
 
        Dim query = db.spFindAgent(intID, ShowHidden, intStartIndex, cmbFirstNameSelect.Text, cmbLastNameSelect.Text, "", "", "", "")  
 
        For Each z In query  
            InputAgent.PageIndex = z.RowNumber - 1  
            Exit For  
        Next  
    End Sub  
 
    'Protected Sub srcAgent_Inserting(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)  
    '   If e.Exception Is Nothing Then  
    '       'InputAgent.ChangeMode(FormViewMode.Edit)  
    '   End If  
    'End Sub  
 
    'Protected Sub srcAgent_Inserted(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)  
    '   If e.Exception Is Nothing Then  
    '       Dim tbx As TextBox = InputAgent.FindControl("tbxID")  
    '       Dim lngID As Long = CType(tbx.Text, Long)  
    '       InputAgent.ChangeMode(FormViewMode.Edit)  
    '       Dim NewAgent As tblAgent = CType(e.ReturnValue, tblAgent)  
    '       Session("AgentFindID") = lngID  
    '       FindDynamic(0, lngID)  
    '   End If  
    'End Sub  
 
    Protected Sub srcAgent_Updating(ByVal sender As Object, ByVal e As ObjectDataSourceMethodEventArgs)  
        Dim NewAgent As tblAgent = CType(e.InputParameters(1), tblAgent)  
        'If NewAgent.Id = 0 Then  
        '   NewAgent.AuthorUserName = User.Identity.Name  
        '   NewAgent.ViewCount = 0 
        'End If  
    End Sub  
 
    Protected Sub srcAgent_Updated(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)  
        If e.Exception Is Nothing Then  
            Dim NewAgent As tblAgent = CType(e.ReturnValue, tblAgent)  
            'Response.Redirect("~/Authenticated/CodeSamples/Default.aspx?entryId=" & NewAgent.ID)  
        End If  
    End Sub  
 
    Protected Sub frmAgent_ItemUpdated(ByVal sender As Object, ByVal e As FormViewUpdatedEventArgs)  
        If Not e.Exception Is Nothing Then  
            e.KeepInEditMode = True 
            e.ExceptionHandled = True 
            ValidationUtility.ShowValidationErrors(Me, e.Exception)  
        End If  
    End Sub  
 
    Protected Sub frmAgent_ItemInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs)  
        If Not e.Exception Is Nothing Then  
            e.KeepInInsertMode = True 
            e.ExceptionHandled = True 
            ValidationUtility.ShowValidationErrors(Me, e.Exception)  
        End If  
    End Sub  
 
    Protected Sub InputAgent_DataBound _  
     (ByVal sender As Object, ByVal e As System.EventArgs) _  
     Handles InputAgent.DataBound  
 
        Dim tbx As TextBox = InputAgent.FindControl("tbxID")  
        If tbx Is Nothing Then  
            Exit Sub  
        ElseIf tbx.Text <> "" Then  
            Exit Sub  
        End If  
 
        tbx.Text = "0" 
        Dim cbx As Checkbox = InputAgent.FindControl("cbxMarkedForUpdate")  
        cbx.Checked = False 
 
        tbx = InputAgent.FindControl("tbxPctOfCommission")  
        tbx.Text = "50" 
 
        tbx = InputAgent.FindControl("tbxCountry")  
        tbx.Text = "US" 
 
        tbx = InputAgent.FindControl("tbxtblName")  
        tbx.Text = "tblAgent" 
 
        Dim cmb As RadComboBox = InputAgent.FindControl("cmbState")  
        cmb.Text = "MA" 
 
        cbx = InputAgent.FindControl("cbxHidden")  
        cbx.Checked = False 
 
    End Sub  
 
End Class  
 

Also, I am using using a Linq class derived from a custom base class.  If you need this as well, I can include text or send the files.  Let me know.
0
Iana Tsolova
Telerik team
answered on 06 Mar 2008, 11:27 AM
Hi Alan,

I still can't see anything disturbing in your code that can cause that error. Could you please tell us what other controls do you have on your page? Does the error appear as frequently as the trial license message is showing on the page?

Regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Alan
Top achievements
Rank 1
answered on 06 Mar 2008, 02:28 PM
I fixed the problem.  The solution was right there in the error message, but since I'm new to this type of programming, it didn't hit me at first.  Apparently, RadScriptManager doesn't work with trace enabled. I had that directive in my page declaration and when I removed it, things worked like a charm.  Thanks for your help.
0
Alan
Top achievements
Rank 1
answered on 06 Mar 2008, 02:31 PM
How do I mark a reply as the answer?
0
Cesar
Top achievements
Rank 1
answered on 10 Jun 2008, 11:32 PM
I've the same error, but my trace is disabled and I don't know what I can do to resolve it.
The problem occurs when I try close a RadWindow sending a parameter and calling the ClientCallBackFunction function.

Tks,

Cesar Vilarim
0
Vlad
Telerik team
answered on 11 Jun 2008, 05:27 AM
Hi Cesar,

Can you post an example where we can reproduce this?

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Cesar
Top achievements
Rank 1
answered on 11 Jun 2008, 01:46 PM
I encapsulate the RadWindow control in a customized webcontrol called RadLov (List of Values) - RadLov.cs.
This control will be opened and will receive a page with a GridView or a RadGrid control to show a list of values for selection (Grid.aspx).
When I select an item, occasionally that message appears.


RadLov.cs
#region Usings 
 
using System; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
using System.Text; 
using System.Collections.Generic; 

#endregion 
 
namespace Stefanini.Web.WebControls 
    /// <summary> 
    ///          
    /// </summary> 
    [ToolboxData("<{0}:RadLov runat=server></{0}:RadLov>")] 
    public class RadLov : WebControl 
    { 
        private RadWindowManager radWManager; 
        private RadWindow Janela; 
 
        public event EventHandler<LovItemSelectedEvent> Selecionou; 

        #region Properties 
        public string ControleStart { getset; } 
        public string ControleOrigemTexto { getset; } 
        public string ControleRetorno { getset; } 
        public string Classe { getset; } 
        public string Titulo { getset; } 
        #endregion 

        #region Eventos 
        protected override void OnInit(EventArgs e) 
        { 
            CriarComponentes(); 
            base.OnInit(e); 
        } 
        #endregion 

        #region Métodos 
        private void CriarComponentes() 
        { 
            this.CssClass = "modalPopup"
 
            radWManager = new RadWindowManager(); 
            Janela = new RadWindow(); 
            Janela.Behaviors = WindowBehaviors.Close; 
            Janela.Skin = "Vista"
            Janela.Width = Unit.Pixel(500); 
            Janela.Height = Unit.Pixel(500); 
            Janela.ClientCallBackFunction = "CallBackFunction"
            if (!string.IsNullOrEmpty(ControleOrigemTexto)) 
            { 
                Janela.OffsetElementID = "Area"
            } 
            Janela.Modal = true
            Janela.NavigateUrl = "Grid.aspx"
            if (!string.IsNullOrEmpty(Titulo)) 
            { 
                Janela.Title = Titulo; 
                Janela.VisibleTitlebar = true
            } 
            else 
            { 
                Janela.VisibleTitlebar = false
            } 
 
            radWManager.Windows.Add(Janela); 
 
 
            if (!string.IsNullOrEmpty(ControleStart)) 
            { 
                radWManager.Windows[0].OpenerElementID = ControleStart; 
            } 
 
            Controls.Add(radWManager); 
 
            StringBuilder sb = new StringBuilder(); 
 
            sb.Append("function CallBackFunction(radWindow, returnValue){"); 
            sb.Append("var oArea = document.getElementById('" + ControleRetorno + "');"); 
            sb.Append("if (returnValue) oArea.value = returnValue;"); 
            sb.Append("else alert ('Nenhum texto retornado.');__doPostBack('" + ControleRetorno + "', returnValue);}"); 
 
            if (!Page.ClientScript.IsClientScriptBlockRegistered("startRad")) 
            { 
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "startRad", sb.ToString(), true); 
            } 
        } 
 
        public void Selecionar(List<LovItem> lovs) 
        { 
            LovItemSelectedEvent evento = new LovItemSelectedEvent(lovs, "Classe"); 
            try 
            { 
                if (Selecionou != null
                { 
                    Selecionou(this, evento); 
                } 
            } 
            catch (Exception err) 
            { 
                throw new Exception(err.ToString()); 
            } 
        } 
        #endregion 
    } 
 
    public class LovItemSelectedEvent : EventArgs 
    { 
        private List<LovItem> _lista; 
        public List<LovItem> Lista 
        { 
            get { return _lista; } 
            set { _lista = value; } 
        } 
 
        private string _classInstanciated; 
        public string ClassInstanciated 
        { 
            get { return _classInstanciated; } 
        } 
 
        public LovItemSelectedEvent(List<LovItem> lista, string classInstanciated) 
        { 
            _lista = lista; 
            _classInstanciated = classInstanciated; 
        } 
    } 

Grid.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Grid.aspx.cs" Inherits="Grid" Trace="false" %> 
 
<%@ Register Assembly="Telerik.Web.UI, Version=2008.1.515.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" 
    Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
 
    <script type="text/javascript"
    function GetRadWindow() 
    { 
       var oWindow = null
       if (window.radWindow) oWindow = window.radWindow; 
       else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
       return oWindow; 
    } 
    function CloseWindow() 
    { 
       GetRadWindow().Close(); 
    } 
    function OK_Clicked(retorno) 
    { 
        var oWindow = GetRadWindow(); 
        oWindow.Close(retorno); 
    } 
 
    </script> 
 
    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FNACReloadConnectionString %>" 
            SelectCommand="SELECT [idArtista], [nmArtista], [nmSobrenome] FROM [TWCR_ARTISTA]"
        </asp:SqlDataSource> 
         
              
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        </telerik:RadAjaxManager> 
 
         
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true"
        <ContentTemplate> 
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True"  
                    AllowSorting="True" Width="100%" 
                    AutoGenerateColumns="False" DataKeyNames="idArtista, nmArtista, nmSobrenome" DataSourceID="SqlDataSource1"  
                    onrowcommand="GridView1_RowCommand"
            <Columns> 
                <asp:BoundField DataField="idArtista" HeaderText="idArtista" InsertVisible="False" 
                    ReadOnly="True" SortExpression="idArtista" /> 
                <asp:ButtonField DataTextField="nmArtista" HeaderText="nmArtista" SortExpression="nmArtista" /> 
                <asp:BoundField DataField="nmSobrenome" HeaderText="nmSobrenome" SortExpression="nmSobrenome" /> 
            </Columns> 
        </asp:GridView> 
        </ContentTemplate> 
        </asp:UpdatePanel> 
         
    
    </div> 
    <input id="Hidden1" type="hidden" runat="server" name="Hidden1" /> 
    </form> 
</body> 
</html> 

Grid.aspx.cs
using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
 
public partial class Grid : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
    { 
        if (e.CommandName == string.Empty) 
        { 
            int index = Convert.ToInt32(e.CommandArgument); 
            string codigo = Convert.ToString(GridView1.DataKeys[index].Values[0]); 
            string nome = Convert.ToString(GridView1.DataKeys[index].Values[1]) + " " + Convert.ToString(GridView1.DataKeys[index].Values[2]); 
            string fds = codigo + ";" + nome; 
            RadAjaxManager1.ResponseScripts.Add("OK_Clicked('" + fds + "');"); 
        } 
    } 
 







Tks,

Cesar Vilarim
0
Iana Tsolova
Telerik team
answered on 16 Jun 2008, 09:00 AM
Hi Cesar,

Thank you posting a sample code.

Could you please give us some additional information to help us solve your problem:
    Are you using the trial or the dev version of RadControls for ASP.NET AJAX? 
    Does the message appear as frequent as the controls licence message?
    When you receive the message, please check if the error is near "Telerik.Web.UI 2008...".

If you are using trial version, this message will stop disturbing you after purchasing a developer version.

Let us know if this helps.

Kind regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nicolaï
Top achievements
Rank 2
answered on 15 Oct 2008, 06:44 AM
Hello.

I had the exact same error after upgrading to the latest version (to fix another bug)...

For me, it was an updatepanel with async trigger... It's not the first time: whenever I use the "standard" updatepanels with telerik, it causes bugs and errors.
Removing the "standard" asp:updatepanel removed all errors..
Sometimes it displays the client side name of the updatepanel as text on the page around the controls.
This time it was causing the error:
"
Sys.webforms.pagerequestmanagerparsererrorexception
[....]
Error parsing near ' <!DOCTYPE html P'
"

Best regards,
Nicolai
(ps: seen same error with previous versions too)
0
Iana Tsolova
Telerik team
answered on 15 Oct 2008, 03:12 PM
Hello Nicolai,

I would suggest you to use only one approach, MS UpdatePanel or RadAjaxManager, at a time for updating particular content. Otherwise the UpdatePanels created by the RadAjaxManager and the MS UpdatePanel may interweave and result with unexpected behavior and errors.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Alan
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Alan
Top achievements
Rank 1
Cesar
Top achievements
Rank 1
Vlad
Telerik team
Nicolaï
Top achievements
Rank 2
Share this question
or