asp.netajaxiistelerik

My Asp.Net page postbacks seems to have a fixed number of postbacks before the page resets


--- context of my issue: ---

I'm testing in VS 2022 and start the web site with IIS Express (Chrome). After chain selecting 10+ items in an AutoPostBack=true combobox within an UpdatePanel, the page resets afer successfully processing 9 of them. By reset I mean that at Page_PreLoad, where everything is fine when it works, the ViewState is empty and the controls are not instanciated anymore for the exact same page and exact same logic.

The issue was found during normal execution but it required much more gymnastic to reproduce so I resricted the test to that combobox and added a thread sleep of 3 sec in the callback method to simulate. It always stops working after 9 regardless of how long the callback sleeps.

--- The questions: ---

Is there some kind of limit to the number of chained postbacks with ajax or IIS Express or IIS or whatever else that could do what I describe?

Searching the net all I found didn't apply; the viewstate size doesn't grow and is quite small at 128 bytes, the number of available and max threads in the pool doesn't shrink by more than 1, the size of the requests are fine.

--- The layout and code: ---

We have a page with a panel that creates a list of instances of a user control containing various controls in various PageViews and only one PageView is shown per instance and only one instance will be the one with the issue in the panel. Not the best way to build the usercontrol but I inherited the site as is.

I cannot post formal code unfortunatly but I'll try to give as much code as possible to illustrate the context of the controls.

****** The user Control ******

I only kept the Page view with the issue because the others are not relevent.

    <%@ Control Language="C#" AutoEventWireup="true" %>
    <td class='<%# TdClass %>'>
        <telerik:RadPageView ID="PV1 runat="server">
            some controls
        </telerik:RadMultiPage>
        <telerik:RadPageView ID="PV2 runat="server">
            some controls
        </telerik:RadMultiPage>

        <telerik:RadPageView ID="PV3" runat="server">
            <div style="width: 75px; float: left;"> 
                <asp:UpdatePanel ID="UP1" runat="server" >
                    <ContentTemplate>
                        <telerik:RadSearchBox ID="Combo1" runat="server" Width="100%" DataTextField="Descr"
                            DataValueField="Id" ZIndex="7001" EmptyMessage="- nom -" ShowSelectItem="true"
                            SelectItemText="" ExpandAnimation-Type="None" CollapseAnimation-Type="None"
                            AutoPostBack="true" OnSelectedIndexChanged="Combo1_SelectedIndexChanged" >
                        </stm:STMRadSearchBox>
                    </ContentTemplate>
                </asp:UpdatePanel>
           </div>
        </telerik:RadPageView>
    </telerik:RadMultiPage>
    </td>
        protected void Combo1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Thread.Sleep(3000);
        }
****** The panel creating a List of UserControl ******
    <%@ Control Language="C#" AutoEventWireup="true" %>
    <telerik:RadAjaxPanel ID="IIRAP" runat="server">
    <div class="Content">
        <span id="tata"></span>
        <telerik:RadListView ID="LVI" runat="server" GroupItemCount="3" OnNeedDataSource="LVI_NeedDataSource"
            OnItemCreated="LVI_ItemCreated" OnPreRender="LVI_PreRender" Visible="<%# CanViewIntervenant %>">
            <LayoutTemplate>
                <table>
                    <tr id="groupPlaceholder" runat="server">
                    </tr>
                </table>
            </LayoutTemplate>
            <GroupTemplate>
                <tr>
                    <uc:ICTL ID="itemPlaceholder" runat="server" />
                </tr>
            </GroupTemplate>
            <ItemTemplate>
                <uc:ICTL ID="ICTL1" runat="server" />
            </ItemTemplate>
            <EmptyItemTemplate>
                <th>
                    &nbsp;</td>
                    <td>
                        &nbsp;
                    </td>
            </EmptyItemTemplate>
        </telerik:RadListView>
    </div>
    </telerik:RadAjaxPanel>
****** The page using the panel ******
    <%@ Page Language="C#"  %>
    <%@ Register Src="~/UserControl/Detail.ascx" TagPrefix="uc" TagName="Detail" %>
    <asp:Content ID="Content2" ContentPlaceHolderID="MC" runat="server" style="height: 100%">
    <div id="divPageContent">
        <asp:ValidationSummary ID="ValidationSummarySave" runat="server" ValidationGroup="Save" CssClass="errorSummary" Style="margin-top: 30px;" />
        <telerik:RadPanelBar ID="PD1" runat="server" Width="100%" ExpandMode="MultipleExpandedItems">
            <Items>
                <telerik:RadPanelItem Value='<%# RadPanelItemValue.Intervenants.ToString() %>' Text="Intervenants"
                    Expanded="true">
                    <Items>
                        <telerik:RadPanelItem>
                            <ItemTemplate>
                                <uc:DetailID="II1" runat="server" />
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
    </div>
   </asp:Content>

Solution

  • Thanks all for your inputs. What sent my thought in the right direction was the fact that the postback has to complete before sending another one. I explored that idea before without finding a solution, which is wierd since I must not be the first one to have such issue. I'm sure it's out there and just never stumbled upon it for some reasons. A solution that worked came from an unexpected source, chatGPT of all places. Just in case it might help someone else although I suspect that there are better solutions out there since it seems like an awkward way to deal with this issue but here it is:

            <script type="text/javascript">
                var _requestsAdded = false;
                function pageLoad() {
                    if (_requestsAdded == false) {
                        var prm = Sys.WebForms.PageRequestManager.getInstance();
                        prm.add_beginRequest(BeginRequestHandler);
                        prm.add_endRequest(EndRequestHandler);
                        _requestsAdded = true;
                    }
                }
                function BeginRequestHandler(sender, args) {
                    //Start of PostBack.
                    var element= document.getElementById('<%= serverSideControl.ClientID %>');
                    element.control._enabled = false
                }
    
                function EndRequestHandler(sender, args) {
                    //end of postback
                }
            </script>