Problem with RadListBox & AjaxManager

11 posts, 0 answers
  1. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 08 Oct 2012 Link to this post

    After some action (ComboBoxSelectedItemChange) it throws the Console Error: Source and destination listbox can't be the same.

     I try to fix and understand the problem, but I can't. Please, help as fast as possible!
     
    Here is my used telerik components and their properties:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                       <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="RadListBoxGroups">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="RadComboBoxPolice">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
      </telerik:RadAjaxManager>
              <table>
              <tr>
                  <td>
                     <telerik:RadListBox ID="RadListBoxADGroups" runat="server" AllowTransfer="True" DataSourceID="ObjectDataSourceADGroup"
                          DataTextField="Name" Height="300px" Width="300px" TransferToID="RadListBoxGroups"
                          EmptyMessage="Active Directory is missing" AutoPostBackOnTransfer="True" OnTransferred="RadListBoxADGroupsTransferred"
                          EnableDragAndDrop="True" TransferMode="Copy">
                          <ButtonSettings TransferButtons="TransferFrom" Position="Right" VerticalAlign="Top"
                              AreaWidth="40" />
                      </telerik:RadListBox>
                      <asp:ObjectDataSource ID="ObjectDataSourceADGroup" runat="server" SelectMethod="SelectADGroups"
                          TypeName="Scheduler.WebClient.ADGroup"></asp:ObjectDataSource>
                  </td>
                  <td>
                   <telerik:RadListBox ID="RadListBoxGroups" runat="server" EmptyMessage="No Sorted Groups"
                          Style="top: 0px; left: 0px; width: 250px; height: 300px" Height="300px" AutoPostBackOnDelete="True"
                          DataKeyField="GroupPoliceId" DataSourceID="ObjectDataSourceFiltGroups" DataTextField="Name"
                          DataValueField="Id" OnDeleted="RadListBoxGroupsDeleted" AllowDelete="True" OnClientDeleting="RadListBoxGroups_Deleting">
                          <ButtonSettings Position="Right" VerticalAlign="Top" AreaWidth="40" />
                      </telerik:RadListBox>
                      <asp:ObjectDataSource ID="ObjectDataSourceFiltGroups" runat="server" SelectMethod="SelectFilteredGroups"
                          TypeName="Scheduler.WebClient.Controller">
                          <SelectParameters>
                              <asp:ControlParameter ControlID="RadComboBoxPolice" Name="politicId" PropertyName="SelectedValue"
                                  Type="Int32" />
                              <asp:ControlParameter ControlID="LabelOwnGName" Name="ownGName" PropertyName="Text"
                                  Type="String" />
                          </SelectParameters>
                      </asp:ObjectDataSource>
                  </td>
              </tr>
              <tr>
                  <td>
                      <asp:Label ID="LabelOwnGName" runat="server" />
                      <asp:ObjectDataSource ID="ObjectDataSourceGrPolices" runat="server" SelectMethod="SelectGroupPolices"
                          TypeName="Scheduler.WebClient.Controller"></asp:ObjectDataSource>
                  </td>
                  <td>
                     <telerik:RadComboBox ID="RadComboBoxPolice" runat="server" DataSourceID="ObjectDataSourceGrPolices"
                          DataTextField="Name" DataValueField="Id" AutoPostBack="True" Width="100px">
                      </telerik:RadComboBox>
                  </td>
              </tr>
          </table>
          </div>
      <br />
      <div class="field-center-error">
          <asp:Label ID="LabelMessage" runat="server" ClientIDMode="Static" />
      </div>

    It's my RadListBox methods:
    protected void RadListBoxADGroupsTransferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e)
    {
       if (e.DestinationListBox != sender)
        {
        foreach (var grpIns in  e.Items.Select(item => new Group { Name = item.Text,
    GroupPoliceId = Convert.ToInt32(RadComboBoxPolice.SelectedValue) }) )
            {
              _sc.InsertGroup(grpIns);
            }
            LabelMessage.Text = Controller.Message;
            RadListBoxGroups.DataBind();
        }
    }
    protected void RadListBoxGroupsDeleted(object sender, Telerik.Web.UI.RadListBoxEventArgs e)
    {
      foreach (var grpDel in e.Items.Select(item => new Group { Id = Convert.ToInt32(item.Value),
    Name = item.Text }))
        {
          _sc.DeleteGroup(grpDel);
        }
        LabelMessage.Text = Controller.Message;
        RadListBoxGroups.DataBind();
    }
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 10 Oct 2012 Link to this post

    Hi Anatoliy,

    The following online demo demonstrates a case scenario of what you are trying to achieve: http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/transfer/defaultcs.aspx.

    I hope it is helpful.

    Regards,
    Ivana
    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
  4. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 11 Oct 2012 Link to this post

    Hi Ivana,

    In that demonstration only Radlist is shown. If you see I have a problem with AjaxManager. It breaks!

    Regards,
    Anatoliy
    the Cinegy team
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 15 Oct 2012 Link to this post

    Hello Anatoliy,

    Try the following configuration of RadAjaxManager.
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadListBoxADGroups" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadListBox ID="RadListBoxADGroups" runat="server" AllowTransfer="True" DataSourceID="SqlDataSource1"
        DataTextField="Name" DataValueField="ID" Height="300px" Width="300px" TransferToID="RadListBoxGroups"
        EmptyMessage="Active Directory is missing" AutoPostBackOnTransfer="True" OnTransferred="RadListBoxADGroupsTransferred"
        EnableDragAndDrop="True" TransferMode="Copy">
        <ButtonSettings TransferButtons="TransferFrom" Position="Right" VerticalAlign="Top"
            AreaWidth="40" />
    </telerik:RadListBox>
    <br />
    <telerik:RadListBox ID="RadListBoxGroups" runat="server" EmptyMessage="No Sorted Groups"
        Style="top: 0px; left: 0px; width: 250px; height: 300px" Height="300px" AutoPostBackOnDelete="True">
        <ButtonSettings Position="Right" VerticalAlign="Top" AreaWidth="40" />
    </telerik:RadListBox>
    You need to make sure the source RadListBox updates itself as well.

    Regards,
    Ivana
    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.
  6. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 16 Oct 2012 Link to this post

    Hello Ivana,

    I try this configuration and it's not helpful:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="RadListBoxADGroups">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadListBoxADGroups" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="RadListBoxGroups">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="LabelMessage" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
               <telerik:AjaxSetting AjaxControlID="RadComboBoxPolice">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadListBoxGroups" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>

    I would be appreciative, if you show me an example of complete customization RadAjaxManager for my Components.
  7. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 18 Oct 2012 Link to this post

    Hello Anatoliy,

    Take a look at the attached page. It all works just fine at my end.

    Regards,
    Ivana
    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.
  8. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 23 Oct 2012 Link to this post

    Hello Ivana,

    I definitely want to find out reason of this problem... So please, Look this Test Project! ADPolices.zip
    I hope this will help us to understand the problem. 

    If it's possible, explain why the Metro style is "ride" on List-box's attached buttons? 
  9. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 25 Oct 2012 Link to this post

    Hello Anatoliy,

    You should add one additional reference to the UpdatedControls in the AjaxSettings of the AjaxManager. Please keep in mind that each RadListBox should update itself and the other RadListBox control. I have slightly modified the provided sample, in order to show you the correct implementation.
    In addition, I have commented the CDN usage in the web.config and I had removed the dll's, in order to reduce the size of the sample. Please find it attached.

    Kind regards,
    Nencho
    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.
  10. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 29 Oct 2012 Link to this post

    Hello Nencho ,

    Thank you for order of correct implementation of Ajax Settings. But Error still present when I change Selected Combo Box Item and then try to pass AdGroup to second list box. What the reason?

    Kind regards,
    Anatoliy
  11. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 01 Nov 2012 Link to this post

    Hi Anatholiy,

    Please consider adding one additional reference in the UpdatedControls section for the RadComboBoxPolice, in order to update both RadListBoxes.

    Please find the modified sample attached.


    Regards,
    Nencho
    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.
  12. Anatoliy
    Anatoliy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    Hi Nencho, thank you! It was really helpful!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017