Question

I have a ASPX page in which I am using JavaScript and ASP components which worked fine but I have added a Telerik combobox and now it is producing an error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) 

I had these things in my JavaScript code which was working fine before I added the Telerik code:

 $(function () {
            $("#<%=CountryCity1.ClientID%>").hide();
...
...

and

<div id="CountryCity1" runat="server"> 

I also have a jQuery autocomplete service in the same code which also stopped working.

Then I replaced this with

   $(function () {
            $("#<%#CountryCity1.ClientID%>").hide();
...
...

and

<div id="CountryCity1" runat="server"> 

And now it's not working on page I have added this code of Telerik

  <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox2" />
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox3" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadComboBox2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox3" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
Was it helpful?

Solution

You need to put you javascript code inside telerik code block as show below:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    function AjaxReq(args) {
        $find("<%= RadAjaxPanel1.ClientID %>").ajaxRequestWithTarget("<%= Button1.UniqueID    %>", '');
    }
</script>
</telerik:RadCodeBlock>

Refer to : http://www.telerik.com/help/aspnet-ajax/ajax-radscriptblock-radcodeblock.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top