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

Unable to Get AJAX Working

15 Answers 219 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 25 Apr 2011, 10:55 AM
Hi, I've been using the Telerik controls on my personal site as an opportunity to use them, but I'm finding it very difficult to get the AJAX working.
The error which I observed in Firebug is:
uncaught exception: [Exception... "'Sys.WebForms.PageRequestManagerParserErrorException: 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 '

<!DOCTYPE html P'.' when calling method: [nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)"  location: "JS frame :: chrome://firebug/content/spy.js :: callPageHandler :: line 744"  data: no]

Line 0


The code is:
using System;
using System.Web.UI;
using Telerik.Web.UI;
using System.IO;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            AddTab("Home", "Home");
            AddPageView(DaveRadTabStrip.FindTabByText("Home"));
            AddTab("Apps","Applications Created by Dave");
            AddTab("Blog","Blog");
            AddTab("Contact","Contact Dave");
        }
 
        /* Using jQuery's document.ready method would only attach the fancybox when the page first loads,
         * which is too early because the content in the RadMultiPage control has not loaded yet and will not
         * work on the other tabs because the content is being loaded using AJAX, so the javascript call
         * at the top of the page does not attach  itself to those newly loaded elements.
         *
         * The piece of javascript needs to be called on each ajax request so it sets up the fancybox on
         * those links. (That is why it is not included in the "if" statement above). To do that, modify the ResponseScripts collection of the RadAjaxManager in your
         * AddPageView method:
         */
        RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
        manager.ResponseScripts.Add("$(\"a.lib\").fancybox({ 'transitionIdn': 'fade','transitionOut': 'fade' });");
    }
 
    private void AddTab(string tabName, string tabText)
    {
        RadTab tab = new RadTab();
        tab.Text = tabText;
        tab.Value = tabName;
        this.DaveRadTabStrip.Tabs.Add(tab);
    }
 
    protected void DaveRadMultiPage_PageViewCreated(object sender, RadMultiPageEventArgs e)
    {
        string userControlName = @"~/UserControls/" + e.PageView.ID + ".ascx";
         
        Control userControl = Page.LoadControl(userControlName);
        userControl.ID = e.PageView.ID + "_userControl";
        e.PageView.Controls.Add(userControl);
    }
 
    private void AddPageView(RadTab tab)
    {
        RadPageView pageView = new RadPageView();
        pageView.ID = tab.Value;
        DaveRadMultiPage.PageViews.Add(pageView);
        tab.PageViewID = pageView.ID;
    }
 
    protected void DaveRadTabStrip_TabClick(object sender, RadTabStripEventArgs e)
    {
        AddPageView(e.Tab);
        e.Tab.PageView.Selected = true;
    }
 
}

The code should look pretty familiar as I copied it from one of the Telerik examples. Load on demand (lazy-loading the tabs).
You can observe the behaviour here.

I'd love to know what I'm doing wrong, if anyone can tell me.

Cheers

15 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 28 Apr 2011, 09:07 AM
Hello David,

I observed the error when launched the provided page, however was not able to determine the cause of it.
To isolate the issue further I would ask you to comment the below code line and see if the error persists:
manager.ResponseScripts.Add("$(\"a.lib\").fancybox({ 'transitionIdn': 'fade','transitionOut': 'fade' });");

Also, please make sure now errors are thrown when ajax is disabled.

Check it out and let me know how it goes.

All the best,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 28 Apr 2011, 11:34 AM
Hi Iana,

The error occurs both when I comment out the jQuery script referred to in your post and when I completely remove AJAX.

Note that it does work fine when I run it on Cassini (F5) and when I publish to my localhost.

Can you think of what it might me on my Hosting provider's environment that might be causing the problem?
Note that I have also re-published a couple of times, and even just copied all the files up there to eliminate the possibility that it was a 1 off issue.

Very peculiar.
0
Iana Tsolova
Telerik team
answered on 29 Apr 2011, 12:05 PM
Hello David,

I lauched the page again and I received the following javascript error on initial load. I am attaching a screentshot of it as well.
"onTabSelecting is not defined"
 
This error is a possible reason for the page not to work correctly. Can you check it out?

Greetings,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 30 Apr 2011, 11:29 AM
Hi Iana,

I have fixed that issue and the page is in an AJAX-free state. But the tab control is not working for some reason.
It works with all the AJAX bells and whisltes on my local dev environment. But the tab control does work at all on my hosted web-space.

I'm starting to think I may have to take this up with the hosting company.
0
Iana Tsolova
Telerik team
answered on 02 May 2011, 11:22 AM
Hi David,

Can you first share the whole page code for a further check?
Additionally, you can try troubleshooting the web resources as described in this article.

Kind regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 02 May 2011, 03:51 PM
Hi Iana,

I have uploaded the whole project/solution to here. You'll be able to run it easily as there is no db backend.

With regards to the link you referred me to for trouble-shooting web resources, there does not seem to be an option for 4.0. Only 2.0 and 3.5. Either way, I did not see a handler for ScriptResource anywhere in the Web.config of my program.

Do I need one?
What would be the appropriate XML for the 4.0 CLR?
If it works on my dev environment, why was it able to do so without that resource?

Cheers
0
Iana Tsolova
Telerik team
answered on 03 May 2011, 12:05 PM
Hi David,

I tested the provided sample and I can confirm it works fine on my side as well.
What I also did it to check what web resources are downloaded and used in the live and the local projects. The one difference is that the fancybox js and css are used only in the local application. But I can definitely say everything is ok with the web resources of the live page so further troubleshooting on the web resources is not needed.
And the other major difference I found is that the live does not have RadAjaxManager nor a RadAjaxLoadingPanel at all. I assume that is why ajax is not working there. The conclusion that RadAjax is missing is done based on the fact that the html that should be rendered from the controls is not available in the page source and no $create() method is available for creating the client objects of the controls.

Can you confirm the master page which is used in both cases is the same?

All the best,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 03 May 2011, 03:39 PM
Hi Iana,

I took AJAX off in a bid to identify whether that was the issue. I should have been clear on that. The exact aspx and cs files which are on the host now are zipped here.
The user controls are supposed to be created in the code-behind event handler for the tab-click events.
Sorry about that.

Cheers
0
Iana Tsolova
Telerik team
answered on 04 May 2011, 09:52 AM
Hello David,

So it seems that issue is not caused by RadAjax. But I am still not sure why the page works properly on local and not on the deployment environment.
Can you try enabling debugging for the live project so we can see if any server error is thrown?

Kind regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 05 May 2011, 10:24 AM
Hi Iana,

Debugging is already enabled:
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0">

I think we are almost out of options. Might have to abandon the load-on-demand. Let me know if there is anything else you can think of.

Cheers
0
Iana Tsolova
Telerik team
answered on 05 May 2011, 02:53 PM
Hi David,

What you can try is running a simple page where the controls are declarative and see if it works properly on the deployment server. Thus we would be able to isolate the issue further.

Other than this, when you have declarative RadTabStrip and RadMultiPage with RadPageViews, you can optimize the page performance by ajaxifying them and setting the RadTabStrip AutoPostBack property to true and the RadMultiPage RenderSelectedPageOnly property to true as well.

Kind regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 08 May 2011, 10:42 AM
Hi Iana,

Thanks for those performance tips.
I worked with the support guys of my hosting company to resolve the problem, and they referred me to this post.
I tried setting the preCondition attribute of the radCompression module to managedHandler, but that did not work:
		<modules runAllManagedModulesForAllRequests="true">
			<remove name="RadCompression"/>
			<add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="managedHandler" />
		</modules>
So, perhaps it was another handler.? I am not sure.

As per the breaking change, the page loads fine and works if you use the full url (all the way to the aspx extension). But if the url does not contain the whole url to the file, it does not work. However, on that breaking change white paper, I found some advice to include an action attribute to the form element - action="Default.aspx" .

Whilst this works, it feels like a hack. Anyhow, I have got it working for now by including that action attribute.
0
Accepted
Iana Tsolova
Telerik team
answered on 09 May 2011, 02:45 PM
Hi David,

Please find more information about this problem and how to solve it at the bottom of this topic.

Regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 12 May 2011, 08:27 AM
Hi Iana,
One last very quick question. Does setting runAllManagedModulesForAllRequests to false mean that the RadCompession module is effectively disabled?
If so, wouldn't it be just as easy to remove the module totally?

Thanks
0
Maria Ilieva
Telerik team
answered on 16 May 2011, 02:43 PM
Hi David,

You have the option to disable the compression for particular pages only if necessary. To do that use the RadCompressionSettings attribute on the page in question:
[Telerik.Web.UI.RadCompressionSettings(HttpCompression = Telerik.Web.UI.CompressionType.None)]  
public partial class Default_Cs : System.Web.UI.Page 
{
    ...
}

If you need to disable the compression for the whole application the best approach is to remove the module totally.

Kind regards,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Ajax
Asked by
David
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
David
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or