RadAjaxManager with items in ItemTemplate

5 posts, 0 answers
  1. AS
    AS avatar
    15 posts
    Member since:
    Feb 2007

    Posted 27 Apr 2009 Link to this post

    I'm having a problem accessing controls in the RadAjaxManager.  The controls are within an item template in the RadPanelBar.  Is there a way to access these?

      Here's a code snippet.  In this example, lbxOrg will be using Ajax to update the lbxContract.  However, I get an error with this - seems like lbxOrg cannot be found by the RadAjaxManager. 

     

     
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
     
    <AjaxSettings> 
     
    <telerik:AjaxSetting AjaxControlID="lbxOrg">  
     
     <UpdatedControls> 
     
    <telerik:AjaxUpdatedControl ControlID="lbxContract"/>  
     
    </UpdatedControls> 
     
    </telerik:AjaxSetting> 
     
    </AjaxSettings> 
     
    </telerik:RadAjaxManager> 
     
     
     
    <telerik:RadPanelBar ID="RadPanelBar1" Width="100%" runat="server" ExpandMode="MultipleExpandedItems" 
     
    Skin="Gray">  
     
    <Items> 
     
    <telerik:RadPanelItem Value="Items" Text="Filters">  
     
    <Items> 
     
     
    <telerik:RadPanelItem Value="FiltersItem">  
     
    <ItemTemplate> 
     
     
     
    <asp:ListBox ID="lbxOrg" runat="server" Rows="10" AutoPostBack="True"   
     
    SelectionMode="Multiple" OnSelectedIndexChanged="lbxOrg_SelectedIndexChanged" 
     
    Width="300px">  
     
    </asp:ListBox> 
     
    <br /> 
     
    <asp:ListBox ID="lbxContract" runat="server" AutoPostBack="True"   
     
    OnSelectedIndexChanged="lbxContract_SelectedIndexChanged" Rows="10" SelectionMode="Multiple" 
     
    Width="100px">  
     
    </asp:ListBox> 
     
    </ItemTemplate> 
     
    </telerik:RadPanelItem> 
     
    </Items> 
     
    </telerik:RadPanelItem> 
     
    </Items> 
     
    </telerik:RadPanelBar> 
     

    Thanks!
    ashah

  2. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 30 Apr 2009 Link to this post

    Hello AS,

    Please find below a sample code snippet that shows the needed approach.

    ASPX:
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1">  
        </telerik:RadScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="lbxOrg">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="lbxContract" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <telerik:RadPanelBar ID="RadPanelBar1" Width="100%" runat="server" ExpandMode="MultipleExpandedItems">  
            <Items> 
                <telerik:RadPanelItem Value="Items" Text="Filters">  
                    <Items> 
                        <telerik:RadPanelItem Value="FiltersItem">  
                            <ItemTemplate> 
                                <asp:ListBox ID="lbxOrg" runat="server" Rows="10" AutoPostBack="True" SelectionMode="Multiple" 
                                    Width="300px" OnSelectedIndexChanged="lbxOrg_SelectedIndexChanged">  
                                    <asp:ListItem>1</asp:ListItem> 
                                    <asp:ListItem>2</asp:ListItem> 
                                    <asp:ListItem>3</asp:ListItem> 
                                </asp:ListBox> 
                                <br /> 
                                <asp:ListBox ID="lbxContract" runat="server" AutoPostBack="True" Rows="10" SelectionMode="Multiple" 
                                    Width="100px" OnSelectedIndexChanged="lbxContract_SelectedIndexChanged">  
                                    <asp:ListItem>1</asp:ListItem> 
                                    <asp:ListItem>2</asp:ListItem> 
                                    <asp:ListItem>3</asp:ListItem> 
                                </asp:ListBox> 
                            </ItemTemplate> 
                        </telerik:RadPanelItem> 
                    </Items> 
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelBar> 
        </form> 
    </body> 
    </html> 
     

    Code-behind:
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Data;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using Telerik.Web.UI;  
     
    public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
              
        }  
     
        protected void lbxOrg_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            ListBox Contract = (ListBox)RadPanelBar1.FindItemByValue("FiltersItem").FindControl("lbxContract");  
            ListBox Org = (ListBox)RadPanelBar1.FindItemByValue("FiltersItem").FindControl("lbxOrg");  
     
            Contract.SelectedIndex = Org.SelectedIndex;  
        }  
        protected void lbxContract_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            ListBox Contract = (ListBox)RadPanelBar1.FindItemByValue("FiltersItem").FindControl("lbxContract");  
            ListBox Org = (ListBox)RadPanelBar1.FindItemByValue("FiltersItem").FindControl("lbxOrg");  
     
            Org.SelectedIndex = Contract.SelectedIndex;  
        }  
    }  
     
     


    Regards,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. AS
    AS avatar
    15 posts
    Member since:
    Feb 2007

    Posted 30 Apr 2009 Link to this post

    Unfortunately, this is actually exactly what I had before...and it's not working.

    As soon as I put the lbxOrg and lbxContract into the RadAjaxManager , I start getting javascript errors. I'm able to access my listboxes with no problem in the codebehind using FindControl.  I'm just curious why I can't seem to put lbxOrg or lbxContract into the RadAjaxManager (or any controls I've placed within the RadPanelBar ItemTemplate) without Javascript errors. I can put other controls that are outside of the RadPanelBar into the RadAjaxManger with no errors.

     

     

  5. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 30 Apr 2009 Link to this post

    Hello AS,

    The provided code snippet works without any error (it's tested). If the problem persists on your side I suggest you open a support ticket and send us a simple running project reproducing the problem. Thus way we can investigate and eventually fix it.

    Sincerely yours,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Steven
    Steven avatar
    3 posts
    Member since:
    Jun 2014

    Posted 16 Dec 2014 Link to this post

    AS,

    Try setting AjaxControlID to "RadPanelBar1" instead of "lbxOrg". I just ran into this problem and this fixed it.Basically tell the source control to be the PanelBar instead of its child controls in its ItemTemplate.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017