No way to determine when control will be updated in requestStart

2 posts, 0 answers
  1. Jessica
    Jessica avatar
    1 posts
    Member since:
    Mar 2014

    Posted 09 Jun 2015 Link to this post

    Hallo, sorry for my english.

    I need to determine when control(panel) will be updated by radajaxmanager in theyrs onRequestStart. I need this to call kendo.destroy before postback to destroy existing kendo controls.

    Problem is that objects, recieved from get_ajaxSettings have property with ClientID's of controls (InitControlID) and get_eventTarget returns uniqueId. Because of that, i cannot get controls that will be updated from settings collection for current request.

    I've found _postbackControlClientID in ajax setting object, but that property contains invalid id, not like in InitControlID, but very similar.

    Seems like there is no way to determine in onRequestStart event controls that will be updated.

    So, that will be great if telerik developers add a function to onRequestStart eventArgs like get_currentAjaxSetting for situations like this.


  2. Konstantin Dikov
    Konstantin Dikov avatar
    2088 posts

    Posted 12 Jun 2015 Link to this post

    Hello Jessica,

    The client-side AJAX settings collection will contain information about the ClientID of the controls, because those are the IDs generated for the controls with ClientIDMode "AutoID". However, once you have the generated ClientID of the control you can easily split that ID by "_" and the last part will be the ID of the control. Furthermore, if you have more complex structure and the target control is nested control, you may have to find the wrapping AJAX panel, so you can find the ID of the control in the AJAX settings.

    For your convenience, following is an example for retrieving the IDs of all updated controls:
    <telerik:RadWindow runat="server" ID="RadWindow1" VisibleOnPageLoad="true" Width="800px" Height="300px">
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                <script type="text/javascript">
                    function requestStart(sender, args) {
                        var ajaxControlClientID = getAjaxContainer(args.EventTargetElement);
                        var ajaxSettings = sender.get_ajaxSettings();
                        var controlsThatWillBeUpdated = [];
                        for (var i = 0; i < ajaxSettings.length; i++) {
                            if (ajaxSettings[i].InitControlID == ajaxControlClientID) {
                                var updatedControls = ajaxSettings[i].UpdatedControls;
                                for (var z = 0; z < updatedControls.length; z++) {
                                    var cleanID = getCleanID(updatedControls[z].ControlID);
                    function getAjaxContainer(element) {
                        while (element.className.indexOf("RadAjaxPanel") < 0) {
                            element = element.parentElement;
                        return element.children[0].id;
                    function getCleanID(id) {
                        var splitID = id.split("_");
                        return splitID[splitID.length - 1];
            <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
                <ClientEvents OnRequestStart="requestStart" />
                    <telerik:AjaxSetting AjaxControlID="Wrapper1">
                            <telerik:AjaxUpdatedControl ControlID="Wrapper1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel1" />
                            <telerik:AjaxUpdatedControl ControlID="Panel2" />
                    <telerik:AjaxSetting AjaxControlID="Wrapper2">
                            <telerik:AjaxUpdatedControl ControlID="Wrapper2" />
                            <telerik:AjaxUpdatedControl ControlID="Panel3" />
                            <telerik:AjaxUpdatedControl ControlID="Panel4" />
            <asp:Panel runat="server" ID="Wrapper1">
                <asp:Button runat="server" ID="Button1" Text="Update panel 1 & 2" />
            <asp:Panel runat="server" ID="Panel1">panel1</asp:Panel>
            <asp:Panel runat="server" ID="Panel2">panel1</asp:Panel>
            <asp:Panel runat="server" ID="Wrapper2">
                <asp:Button runat="server" ID="Button2" Text="Update panel 3 & 4" />
            <asp:Panel runat="server" ID="Panel3">panel3</asp:Panel>
            <asp:Panel runat="server" ID="Panel4">panel4</asp:Panel>

    Hope this helps.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top