New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

The AjaxManager Designer Does Not Locate All Controls

Environment

Product Progress® Telerik® UI for ASP.NET AJAX

Description

What can I do when the AjaxManager is not able to locate some controls on a page but they are still AJAX-enabled and updated by AjaxManager?

Solution

To fix this issue and depending on your scenario, use any of the following approaches:

  • If the controls are placed in asp:Table cells—Set an ID for the table cells and include the runat="server" configuration. As a result, the designer will locate all the controls within the table.

    The following example demonstrates how to set the ID for table cells of an asp:Table and set runat='server'.

    <div class='tabbedCode'><pre lang="ASP.NET"><code>        &lt;asp:Table ID="Table1" runat="server"&gt;
                &lt;asp:TableRow runat="server" ID="rol_1"&gt;
                    &lt;asp:TableCell runat="server" ID="cell_11"&gt;
                        &lt;asp:Panel ID="Panel1" runat="server"&gt;
                            &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
                            &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
                        &lt;/asp:Panel&gt;
                    &lt;/asp:TableCell&gt;
                    &lt;asp:TableCell runat="server" ID="cell_12"&gt;&lt;/asp:TableCell&gt;
                    &lt;asp:TableCell runat="server" ID="cell_13"&gt;&lt;/asp:TableCell&gt;
                &lt;/asp:TableRow&gt;
                &lt;asp:TableRow runat="server" ID="row_2"&gt;
                    &lt;asp:TableCell runat="server" ID="cell_21"&gt;
                        &lt;div runat="server" id="div1"&gt;
                            &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;
                        &lt;/div&gt;
                    &lt;/asp:TableCell&gt;
                    &lt;asp:TableCell runat="server" ID="cell_22"&gt;&lt;/asp:TableCell&gt;
                    &lt;asp:TableCell runat="server" ID="cell_23"&gt;&lt;/asp:TableCell&gt;
                &lt;/asp:TableRow&gt;
    &lt;/asp:Table&gt;
    ````
    

    After you have set the ID of the table cells and the runat="server" configuration, the designer can locate the button, check-box, and text box, and you can AJAXify the controls in the asp:Table cells as demonstrated by the following example.

    <div class='tabbedCode'><pre lang="ASP.NET"><code>        &lt;telerik:RadScriptManager ID="RadScriptManager1" runat="server"&gt;
    &lt;/telerik:RadScriptManager&gt;
    &lt;telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"&gt;
                &lt;AjaxSettings&gt;
                    &lt;telerik:AjaxSetting AjaxControlID="Button1"&gt;
                        &lt;UpdatedControls&gt;
                            &lt;telerik:AjaxUpdatedControl ControlID="TextBox1" /&gt;
                        &lt;/UpdatedControls&gt;
                    &lt;/telerik:AjaxSetting&gt;
                    &lt;telerik:AjaxSetting AjaxControlID="CheckBox1"&gt;
                        &lt;UpdatedControls&gt;
                            &lt;telerik:AjaxUpdatedControl ControlID="TextBox1" /&gt;
                        &lt;/UpdatedControls&gt;
                    &lt;/telerik:AjaxSetting&gt;
                &lt;/AjaxSettings&gt;
    &lt;/telerik:RadAjaxManager&gt;
    ````
    

  • If the control is nested in a template of a composite control—The templates may prevent the designer from recognizing the wrapped controls. In such scenarios, it is recommended that you add the AJAX settings programmatically. This, together with using the FindControl method, enables the AjaxManager to AJAX-enable and update controls at all levels of the application.

    For example, if the control you want to update is located within DockableObject web control, you can find it at runtime by using RadDockableObject.FindControl("<controlID>") and then set it as an updated control. For more information, refer to the AJAX RadDock online demo.

  • If the controls are placed in a WebUserControl—The previous case is valid here as well. You can use the same approach and add the AJAX settings dynamically.

    For example, if the control is placed in a WebUserControl, you can find it at runtime by using WebUserControl1.FindControl("<controlID>") and then set it as an updated control. For more information, refer to the article on how to AJAX-enable user controls.

  • If the controls are placed in different content of a MasterPage scenario—Use the example for adding the AJAX setting programmatically as the controls are hidden from the designer when placed in a content place holder. In this case, you can find the control at runtime by using ContentPlaceHolder1.FindControl("<controlID>") and then set it as an updated control.

See Also

In this article