Today I ran into a strange problem with a complex form that in ASP.NET WebForms. My form is using Telerik UI for ASP.NET AJAX, and has (among other things), two RadAsyncUpload controls and two RadListView controls. The form had previously worked successfully but after adding the second RadListView control we noticed that the first RadListView control wasn’t getting populated in some circumstances.
The behavior was particularly strange because, when stepping through the code, the NeedDataSource event was triggered and the records were returned correctly. But for some reason the data wasn’t getting updated on the client. If I commented out the code that loaded the data for the new RadListView control I added, then the old one started working again. And if I switched the order of the load, then the old RadListView got populated but the first one did not. What was happening? No errors were logged, it was as if it was swallowing the request.
As it turns out, that was pretty much true. By the design, ASP.NET AJAX cancels an ongoing AJAX request if another one is initiated prior to getting the response back from the first. I am using the RadAjaxManager control to coordinate some of these Ajax events, and it also has this behavior by default. But they provide a mechanism for overriding it – the RequestQueueSize property. The default is “0”, but you can increase it.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
<RadAjaxControl>.RequestQueueSize = 3
That solved my problem. What a relief! I was afraid I’d have to rip out all of this code and start over.