RadAjax not firing on 1st click after client side event handler

740 Views Asked by At

I'm using RadAjaxManager to ajaxify some WebForms controls. The ajax works fine in all scenarios except one:

I have a LinkButton:

<asp:LinkButton ID="lnkSaveButton" 
                    Text="Save" 
                    OnClick="lnkSaveButton_Click"
                    OnClientClick="if ( ! validateValidation()) return false;"
                    runat="server" />

The validateValidation function fires some client side page validation on my form controls, which returns false to block the form from submitting if the Page is invalid.

In the case that the Page is invalid, all of the controls targeted by RadAjaxManager fail to fire their ajax request on the first click (only) after the validation completes.

Any subsequent click on the ajaxified control fires the request correctly. It's also worth noting that all of the Ajaxified controls work correctly after one ajaxified control has been clicked once. Clicking on any non-ajaxified control (not targeted by RadAjaxManager) has no impact.

It's also worth noting that if I replace RadAjaxManager with simple RadAjaxPanels I get the exact same result as described above.

What is going on and how do I fix it?

1

There are 1 best solutions below

1
On
  • ensure you are not adding AjaxSettings that encompass RadAjaxPanel controls

  • make sure no script errors are thrown, especially by the validation

  • try calling the ajaxRequsetWithTarget in the client-side handler if validation is successful, something like:

        <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
            <script>
                function validateValidation() {
                    var validatinPassed = true;
                    $find("<%=RadAjaxManager.GetCurrent(Page).ClientID%>").ajaxRequestWithTarget('<%= lnkSaveButton.UniqueID %>', '');
                    return false;
                }
            </script>
        </telerik:RadCodeBlock>
        <asp:LinkButton ID="lnkSaveButton"
                        Text="Save"
                        OnClick="lnkSaveButton_Click"
                        OnClientClick="if (! validateValidation())
                            return false;"
                        runat="server" />
        <asp:Label ID="Label1" Text="text" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="lnkSaveButton">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="lnkSaveButton" />
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
    

    and a sample handler for testing

    protected void lnkSaveButton_Click(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToString();
    }