This is a migrated thread and some comments may be shown as answers.

RadAjaxManager with items in ItemTemplate

4 Answers 119 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
AS
Top achievements
Rank 1
AS asked on 27 Apr 2009, 07:58 PM
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

4 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 30 Apr 2009, 12:08 PM
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.
0
AS
Top achievements
Rank 1
answered on 30 Apr 2009, 12:17 PM

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.

 

 

0
Paul
Telerik team
answered on 30 Apr 2009, 12:36 PM
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.
0
Steven
Top achievements
Rank 1
answered on 16 Dec 2014, 09:34 PM
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.
Tags
PanelBar
Asked by
AS
Top achievements
Rank 1
Answers by
Paul
Telerik team
AS
Top achievements
Rank 1
Steven
Top achievements
Rank 1
Share this question
or