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

Error parsing near Telerik.Web.UI.2008

7 Answers 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Waleed Seada
Top achievements
Rank 2
Waleed Seada asked on 26 May 2008, 06:55 AM
Hello All,
I have build a complex interface with many RadControls on it.

I finally loaded a usercontrols dynamically, when I receive this error message:
Sys.WebForms.PageRequestManagerParserErrorException: the message from the server can not be parsed .........
Details: error parsing near 'Telerik.Web.UI.2008'

The message appears randomly, I don't know where could be the issue ...

Best regards
Waleed

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 May 2008, 07:49 AM
Hi Waleed Seada,

Thank you for your interest in RadControls.

I will appreciate if you provide a demo application which can be debugged locally. Thus we will provide more straight-to-the-point explanation/solution.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Waleed Seada
Top achievements
Rank 2
answered on 26 May 2008, 10:55 AM
Dear Daniel,

I opened a support ticket with sample application attahced.

I Hope you can re-produce the same error...

Support ticket number : 140149

Best regards
Waleed
0
Rosen
Telerik team
answered on 29 May 2008, 05:15 AM
Hi Waleed,

We have examined the code you have sent and found that the paging problem is caused by your user control loading routine. Can you please try removing this line parent.Controls.Clear(); from your LoadUserControl method and see if it helps.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Waleed Seada
Top achievements
Rank 2
answered on 29 May 2008, 06:13 AM
Hello Rosen,

It helps the paging, but the controls are added at the same time, which is not what I want, beside that if I clicked on the same link twice, I will receive error of adding the same control ID.

Best,
Waleed
0
Baatezu
Top achievements
Rank 2
answered on 30 May 2008, 03:07 AM
This is kinda a work around/hack, but it has worked for me when I do dynamic loading

Can you check for the existence of the control before you add it? That way you don't add it twice if it already exists.

Instead of completely removing parents.Controls.Clear(), I'd do
Control control = parent.FindControl("myControl"); 
if(control != null
    parents.Controls.Remove(control); 
This way it won't remove any other controls that are created in whatever object you are trying to insert it into. You can build off this as well to implement my other suggestion since it already checks if the control exists or not. :)
0
Waleed Seada
Top achievements
Rank 2
answered on 01 Jun 2008, 06:38 AM
Hello Baatezu,

I try to achieve this before cause I want to remove the overhead re-loading the same control many time, when the user click on the same link more than once, when a strange and unexpected result occur; FindControl couldn't fine the control with the ID.

In the debug mode you can see that if you test the same function after adding the control it will work fine, but not in the next trip (same call to load the user control).

This what happen when I try to use your code here.

/Edit : same date
I only want to have one usercontrol loaded in the panel.

Thanks and Best regards,
Waleed
0
Waleed Seada
Top achievements
Rank 2
answered on 01 Jun 2008, 09:28 AM
Hello Guys,

Based on proposed solution, I comment the clear() method when loading user controls dynamically and I substituted the validation to be for any loaded control to be removed using remove() method.

    public void LoadUserControl(string controlName, Control parent)  
    {  
        string userControlID = ((controlName.Split('.')[0]).Replace("/""")).Replace("~""");  
        //Remove the prevuios loaded control, instead of parent.Controls.Clear() which can cause random problem  
        Control control = parent.FindControl(((CurrentControl.Split('.')[0]).Replace("/""")).Replace("~"""));  
        if (control != null)  
        {  
            parent.Controls.Remove(control);  
        }  
        UserControl MyControl = (UserControl)LoadControl(controlName);  
        MyControl.ID = userControlID;  
        parent.Controls.Add(MyControl);  
        CurrentControl = controlName;  
    } 

It is working fine so far, and the paging is fine as well  ....

Best regards,
Waleed
Tags
General Discussions
Asked by
Waleed Seada
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Waleed Seada
Top achievements
Rank 2
Rosen
Telerik team
Baatezu
Top achievements
Rank 2
Share this question
or