Problem in Ajax post back

2 posts, 1 answers
  1. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 01 Mar 2012 Link to this post

    Hi,

    I have a radpanelbar in a RadAjaxUpdate panel . I need to post back the page when i click or expand  the radpanel item . But got an error.
    System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).    at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child)     at Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated)   

    I have the following code
    <telerik:RadAjaxPanel ID="DemoPanelBarPanel" runat="server" EnableAJAX="true">
     
        <telerik:RadPanelBar ID="uxProfileList" OnClientItemClicked="OnClientItemExpand" OnClientItemExpand="OnClientItemExpand" ExpandMode="FullExpandedItem" Width="100%" runat="server">
     
                                <Items>
                                    <telerik:RadPanelItem runat="server" Text="Personal Info" Value="PersonalInfo" Font-Bold="true"  >
                                    </telerik:RadPanelItem>
                                    <telerik:RadPanelItem runat="server" Text="Profile Info" Value="ProfileInfo" Font-Bold="true" >
                                    </telerik:RadPanelItem>
                                    <telerik:RadPanelItem runat="server" Text="Education" Value="Education" Font-Bold="true" >
                                    </telerik:RadPanelItem>
                                    <telerik:RadPanelItem runat="server" Text="WorkExperience" Value="WorkExperience" Font-Bold="true" >
                                    </telerik:RadPanelItem>
                                </Items>
     
                            </telerik:RadPanelBar>
    </telerik:RadAjaxPanel>
    <script  type="text/javascript" language="javascript">
     
        function OnClientItemExpand(sender, args) {
     
     
     
            $find("<%= DemoPanelBarPanel.ClientID%>").ajaxRequestWithTarget("<%= DemoPanelBarPanel.ClientID%>", args.get_item().get_value());
     
     
        }    
    </script>
    DemoPanelBarPanel.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(OnProfileAjaxPanelAjaxRequest);
    void OnProfileAjaxPanelAjaxRequest(object sender, AjaxRequestEventArgs e)
           {
              if (e.Argument.Equals("PersonalInfo"))
               {
                  RadPanelItem item = uxProfileList.Items.FindItemByValue(e.Argument);
               }
           }

  2. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 05 Mar 2012 Link to this post

    Hi,

    Please try to enclose your javascript in a RadCodeBlock and check whether the problem persists.
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
              <script type="text/javascript" language="javascript">
     
                  function OnClientItemExpand(sender, args) {
     
     
     
                      $find("<%= DemoPanelBarPanel.ClientID%>").ajaxRequestWithTarget("<%= DemoPanelBarPanel.ClientID%>", args.get_item().get_value());
     
     
                  }   
              </script>
          </telerik:RadCodeBlock>

    All the best,
    Dimitar Terziev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top