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

Cannot do more than 1 ajaxRequest

2 Answers 89 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Baatezu asked on 07 Jul 2010, 06:23 AM
I was having some trouble with the RadChart inside a RadAjaxPanel.
When I was using a button to trigger an ajaxRequest on the RadAjaxPanel, it worked once, then the $find(<%= RadAjaxPanel1.ClientID %>) is null. I tested this without the chart just to see the baseline, and it still failed to be capable of doing ajaxRequest more than once.

I hope I didn't miss something where this isn't capable of being called multiple times, or else this is a waste of a big post. :)

I've worked up a very simple version setup that reproduces the issue, so hopefully a solution can be found, or I get to find another charting tool...

Now; how to recreate the issue:
First, My Setup
Visual Studio 2010 Professional
Telerik 2010.1.519.40
FireFox 3.66
Firebug 1.54
Windows 7 Enterprise
Second, The Steps
Open Visual Studio
.NET Framework 4
ASP.NET Web Application [Visual C#]
Open Default.aspx
Replace the contents of BodyContent with
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
        <script type="text/javascript"
            //Adding a var here so the ClientID is accessible to the button 
            var panel = '<%= RadAjaxPanel1.ClientID %>'
    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="$find(panel).ajaxRequest('testing'); return false;" /> 
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"  
        <asp:Label ID="Label1" Text="text" runat="server" /> 
At the top add
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
Add Reference to the Telerik.Web.UI.dll
Register the RadScriptManager in web.config [using the lovely automated method attached to the RadScriptManager]
Open Default.aspx.cs
Add after the Page_Load function
        protected void RadAjaxPanel1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) 
            Label1.Text += e.Argument; 
Build the project
Browse Default.aspx in FireFox [I use CTRL+F5 and have FF as my default browser]
Activate and Refresh the page for FireBug
Go to Console in FireBug
Enter the line $find(panel).ajaxRequest("test1"); [Note that 'panel' is the variable we put the RadAjaxPanel1.ClientID into]
The result will be a Post entry at the top of the console pane.
At this point the label will now have 'test1' appended, making the full text 'texttest1'
Returning to the Console in FireBug
Enter the line $find(panel).ajaxRequest("test2");
Here is where we get the error - It says that $find(panel) is null. The behavior I'm expecting is for another Post to occur and the label text be updated to be 'texttest1test2'.
It might be something to do with javascript and panel may have been reset.
To test this, we use the Console and enter
We get the result - "MainContent_RadAjaxPanel1" so we know that it hasn't been blanked.
We can also use the Console with the line
document.getElementById(panel); and we see that it does still exist on the page.
At this point, to test a little further, I installed FireQuery 0.7 [allows FireBug to add jQuery to a page to make it nice and simple to do things from the Console] and decided to see what would occur when I enter
$('#' + panel); and the result is a jQuerified div. I can do hide()/show() and it responds.
I have checked the value of panel in the HTML in Firebug after the page loads, before any post backs and from the Console using panel
var panel = 'MainContent_RadAjaxPanel1'; 
and then again after causing an ajaxRequest from the Console; and they remain the same.
That's what I have for this so far. I hope I'm not missing something simple and stupid, as I'm wont to do that. I got it as simple as I could and still have the problem.
Since I'm working on a project where users can select what data to display... I kinda need to be able to trigger multiple postbacks. This hiccup has me stumped and prevents me from moving forward with the RadChart. Hopefully we'll have a quick solution and I'm an idiot, but... umm... Yea, until then - Helpz!
Thank you

P.S. I've attached a picture showing the error output in FireBug.

2 Answers, 1 is accepted

Sort by
Tom Gioconda
Top achievements
Rank 1
answered on 07 Jul 2010, 09:57 PM
I'm getting this problem too.  The ajax manager can't be found with $find after the ajaxRequest() completes once.  Subsequent calls won't fire, instead producing a notice about the result of the $find call being null.
Top achievements
Rank 2
answered on 07 Jul 2010, 10:09 PM
I don't have my exact solution with me, but [IIRC] I put a AjaxManager on the page and added the label to the updated control for the RadAjaxPanel and then it worked. I've incorporated this into my larger project as well, and it's working fine.

It looks like an issue when there isn't an AjaxManager on the page... I haven't done a lot of testing into exactly what gets it working, as I got it functional and started back in on getting the RadChart working. :)
Asked by
Top achievements
Rank 2
Answers by
Tom Gioconda
Top achievements
Rank 1
Top achievements
Rank 2
Share this question