RadAjaxManagerProxy with RadCodeBlocks ASP.NET AJAX

1 Answer 21 Views
Ajax
önder
Top achievements
Rank 1
önder asked on 18 Oct 2021, 04:16 PM | edited on 18 Oct 2021, 04:17 PM

Hello,

I have an if else condition which is covered by RadCodeBlock. When I try to bind any control as an updated control in RadCodeBlock by using RadAjaxManagerProxy, it throws below error.

For example; rcbCustomer is binded to rlCustomer. But it causes error. Because rlCustomer is in RadCodeBlock.

Here is RadCodeBlock;

                <telerik:RadCodeBlock ID="rcodeCustomer" runat="server">
                    <table class="fieldset-table">
                        <% if (User.IsInRole("ADMIN"))
                            { %>
                        <tr>
                            <td>
                                <telerik:RadLabel runat="server" Text="Customer" Font-Size="Large" ForeColor="Black" />
                            </td>
                            <td>
                                <telerik:RadLabel runat="server" Text=":" ForeColor="Black" Font-Bold="false" />
                            </td>
                            <td>
                                <telerik:RadComboBox MarkFirstMatch="true" ID="rcbCustomer" EmptyMessage="Please Select Customer" runat="server" Width="100%" DataValueField="ID" DataTextField="Name" AutoPostBack="true" OnSelectedIndexChanged="rcbCustomer_SelectedIndexChanged" />
                                <asp:RequiredFieldValidator
                                    runat="server"
                                    Display="Dynamic"
                                    ControlToValidate="rcbCustomer"
                                    ErrorMessage="Customer is required!"
                                    CssClass="validator" />
                            </td>
                            <td class="center" style="width: 100px">
                                <telerik:RadButton runat="server" ID="rbCustomerReload" ToolTip="Reload Customers" Icon-PrimaryIconCssClass="rbRefresh" BackColor="White" OnClick="rbCustomerReload_Click" />
                                <telerik:RadLinkButton runat="server" ToolTip="Add New Customer" Icon-CssClass="rbAdd" BackColor="White" Target="_blank" NavigateUrl="AdminUser.aspx" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <telerik:RadLabel ID="rlCustomer" runat="server" ForeColor="#333333" Font-Bold="false" Font-Size="Medium" Visible="false" />
                            </td>
                        </tr>
                        <%} %>
                    </table>
                </telerik:RadCodeBlock>

Here is RadAjaxManagerProxy;

<telerik:AjaxSetting AjaxControlID="rcbCustomer">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rlCustomer" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rcbCustomerContact" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rlCustomerContact" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rcbCustomerAddress" LoadingPanelID="RadAjaxLoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rlCustomerAddress" LoadingPanelID="RadAjaxLoadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>

Error;

 

Could you please help?

Thanks,

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 21 Oct 2021, 09:33 AM

Hello ├ľnder,

The Correct approach for this scenario would be to use a Panel or any other Container Control and control its Visible property. Controls with Visible="False" do not render on the Page.

Here is how you can do it:

<telerik:RadCodeBlock ID="rcodeCustomer" runat="server">
    <table class="fieldset-table">
        <asp:Panel ID="Panel1" runat="server" Visible='<%# User.IsInRole("ADMIN") %>'>
            <tr>
                <td>
                    <telerik:RadLabel runat="server" Text="Customer" Font-Size="Large" ForeColor="Black" />
                </td>
                <td>
                    <telerik:RadLabel runat="server" Text=":" ForeColor="Black" Font-Bold="false" />
                </td>
                <td>
                    <telerik:RadComboBox MarkFirstMatch="true" ID="rcbCustomer" EmptyMessage="Please Select Customer" runat="server" Width="100%" DataValueField="ID" DataTextField="Name" AutoPostBack="true" OnSelectedIndexChanged="rcbCustomer_SelectedIndexChanged" />
                    <asp:RequiredFieldValidator
                        runat="server"
                        Display="Dynamic"
                        ControlToValidate="rcbCustomer"
                        ErrorMessage="Customer is required!"
                        CssClass="validator" />
                </td>
                <td class="center" style="width: 100px">
                    <telerik:RadButton runat="server" ID="rbCustomerReload" ToolTip="Reload Customers" Icon-PrimaryIconCssClass="rbRefresh" BackColor="White" OnClick="rbCustomerReload_Click" />
                    <telerik:RadLinkButton runat="server" ToolTip="Add New Customer" Icon-CssClass="rbAdd" BackColor="White" Target="_blank" NavigateUrl="AdminUser.aspx" />
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <telerik:RadLabel ID="rlCustomer" runat="server" ForeColor="#333333" Font-Bold="false" Font-Size="Medium" Visible="false" />
                </td>
            </tr>
        </asp:Panel>
    </table>
</telerik:RadCodeBlock>

 

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Ajax
Asked by
önder
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or