Selecting RadPanelItem in code-behind with PersistStateInCookie doesn't work

10 posts, 0 answers
  1. James Steward
    James Steward avatar
    3 posts
    Member since:
    Jul 2009

    Posted 08 Dec 2009 Link to this post

    Hi,
    This seems like a bug to me. I'm trying to persist the state of my RadPanelBar using PersistStateInCookie, which works fine if I'm only updating the RadPanelBar by itself. However, if I try to update the RadPanelBar via another control on the page, like the click event in code-behind of a button, it doesn't work.
    I understand from doing a little research that the cookie resets the state of the RadPanelBar in (or possibly just before) the PreRender event of the RadPanelBar control. This means that it will always overwrite the selection of a RadPanelItem by another control on the page.

    Here is an example of what I'm talking about:
    Default.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
            <Scripts> 
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
            </Scripts> 
        </telerik:RadScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="LoadingPanel1">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="dCurrentPage">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="dCurrentPage" /> 
                        <telerik:AjaxUpdatedControl ControlID="btnSelectPanel" /> 
                        <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadPanelBar1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="dCurrentPage" /> 
                        <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" /> 
                        <telerik:AjaxUpdatedControl ControlID="btnSelectPanel" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
          
          
        </telerik:RadAjaxManager> 
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Transparency="30" 
            BackColor="#E0E0E0">  
            <img src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
                alt="Loading..." style="border: 0;" /> 
        </telerik:RadAjaxLoadingPanel> 
        <div style="float: left; margin-bottom: 10px; width: 270px">  
            <telerik:RadPanelBar runat="server" ID="RadPanelBar1" PersistStateInCookie="True" 
                OnPreRender="RadPanelBar1_PreRender">  
                <Items> 
                    <telerik:RadPanelItem Text="ASP.NET controls" Expanded="true">  
                        <Items> 
                            <telerik:RadPanelItem NavigateUrl="Default.aspx?page=menu" Text="RadMenu">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem NavigateUrl="Default.aspx?page=combobox" Text="RadComboBox">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem NavigateUrl="Default.aspx?page=panelbar" Text="RadPanelBar">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem NavigateUrl="Default.aspx?page=treeview" Text="RadTreeView">  
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem> 
                    <telerik:RadPanelItem Text="WinForms controls">  
                        <Items> 
                            <telerik:RadPanelItem Text="RadMenustrip" NavigateUrl="Default.aspx?page=menustrip">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem Text="RadTabStrip" NavigateUrl="Default.aspx?page=tabstrip">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem Text="RadToolStrip" NavigateUrl="Default.aspx?page=toolbarstrip">  
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem> 
                    <telerik:RadPanelItem Text="Other projects">  
                        <Items> 
                            <telerik:RadPanelItem Text="SiteFinity" NavigateUrl="Default.aspx?page=sitefinity">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem Text="Reporting" NavigateUrl="Default.aspx?page=reporting">  
                            </telerik:RadPanelItem> 
                            <telerik:RadPanelItem Text="RadAjax" NavigateUrl="Default.aspx?page=ajax">  
                            </telerik:RadPanelItem> 
                        </Items> 
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelBar> 
        </div> 
        <div class="smallModule" id="dCurrentPage" runat="server">  
            <div class="rc1">  
                <div class="rc2">  
                    <div class="rc3">  
                        <strong>Current page:</strong> 
                        <style="padding: 5px 10px">  
                            <asp:Literal runat="server" ID="Label1"></asp:Literal></p>  
                    </div> 
                </div> 
            </div> 
        </div> 
        <br /> 
        <div style="display:block">  
            <asp:Button ID="btnSelectPanel" runat="server" Text="Select RadTabStrip" OnClick="btnSelectPanel_Click" /><br /> 
            <href="Default2.aspx">Go to Default2.aspx</a> 
        </div> 
        </form> 
    </body> 
    </html> 
     

    Default.aspx.cs
    using System;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
     
    using System.Data;  
    using System.Configuration;  
    using System.Web.Security;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    using Telerik.Web.UI;  
     
    public partial class Default : System.Web.UI.Page   
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            Response.Cache.SetCacheability(HttpCacheability.NoCache);  
                  
        }  
     
        protected void RadPanelBar1_PreRender(object sender, EventArgs e)  
        {  
            RadPanelItem selectedItem = RadPanelBar1.SelectedItem;  
            if (selectedItem != null)  
            {  
                Label1.Text = String.Format("This is the {0} page", selectedItem.Text);  
            }  
        }  
     
        protected void btnSelectPanel_Click(object sender, EventArgs e)  
        {  
            RadPanelItem item = RadPanelBar1.FindItemByText("RadTabStrip");  
            RadPanelItem owner = item.Owner as RadPanelItem;  
            owner.Expanded = true;  
            item.Selected = true;  
        }  
    }  
     

    Default2.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <div> 
        This is another page.<br /> 
            <href="Default.aspx">Go back to Default.aspx</a> 
        </div> 
        </form> 
    </body> 
    </html> 
     

    If you select an item in the RadPanelBar, then click on the link to Go to Default2.aspx, then go back to the Default.aspx page you will see that the state has been maintained. However, if you click the button to select the "RadTabStrip" item in the RadPanelBar you will see that it does not work.
    If you change PersistStateInCookie to False, clicking on the button does work, but obviously the the state is not maintained.

    I'm sure there is a workaround for this, but it seems to me that it breaks the coding convention of the Page event lifecycle.
    Any thoughts?

    James Steward
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 15 Dec 2009 Link to this post

    Hi James Steward,

    Thank you for reporting this issue.

    It is indeed a bug, so I logged it in our bug-tracking system and updated your Telerik points.

    We will fix the issue in the upcoming weeks.

    Kind regards,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian Cumberledge
    Brian Cumberledge avatar
    44 posts
    Member since:
    Jan 2004

    Posted 24 Feb 2010 Link to this post

    Has this been fixed?
    When I navigate back to the page that has the radPanel, I want to run server side code for the selected radpanelitem.  It always seems to be null on page load.

    RadPanelBar1.SelectedItem.Value

    If fixed, at what point can I get the above value?   Thanks.

  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 08 Mar 2010 Link to this post

    Hello Brian Cumberledge,

    The issue is still pending.

    Please use our Public Issue Tracking System to follow its status and/or vote for it to increase its importance, so that we fix it sooner.

    All the best,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Andy
    Andy avatar
    14 posts
    Member since:
    Jun 2009

    Posted 03 Feb 2011 Link to this post

    Hi,

    Has this issue been fixed? We are having trouble with this

    Thanks
    Andy
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 03 Feb 2011 Link to this post

    Hello Andy,

    I'm afraid that this issue is not resolved yet.

    All the best,
    Yana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Yogesh
    Yogesh avatar
    2 posts
    Member since:
    Jan 2012

    Posted 18 Jul 2012 Link to this post

    Hi Team,

          Do we have any update on this issue now?

    Thanks,
    Yogesh.
  9. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 20 Jul 2012 Link to this post

    Hi Yogesh,

    I checked the issue in both the PITS (http://www.telerik.com/support/pits.aspx#/public/aspnet-ajax/232) and our internal system and as indicated in its status it is already resolved. Please give it a try with any version after Q2 2011 of the Telerik controls and let me know if you encounter any issues.

    All the best,
    Kate
    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. Carlos
    Carlos avatar
    13 posts
    Member since:
    Apr 2015

    Posted 28 May 2015 in reply to Kate Link to this post

    I am using latest version. its stil not working in the item click event if I set NavigateUrl.
  11. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 02 Jun 2015 Link to this post

    Hello James,

    I am afraid that after some further consideration of this behavior, we determine that this is the proper one, because the item navigate to the particular URL rather than posting back to the current page. Please refer to the documentation article below, where it is demonstrated the approach that we suggest to use in such scenario (using the Attributes collection of the Items). The article is in regards to the RadMenu, however the same could be applied on the RadPanelBar:

    http://www.telerik.com/help/aspnet-ajax/menu-itemclick-event-not-fired.html

    Please consider the below implementation:
    <telerik:RadPanelBar runat="server" ID="RadPanelBar1 OnItemClick="RadPanelBar1_ItemClick">
                   <Items>
                       <telerik:RadPanelItem Text="Item 1">
                           <Items>
                               <telerik:RadPanelItem Text="Item 1.1" CustomNavigateUrl="http://www.google.com">
                               </telerik:RadPanelItem>
    .............................

    protected void RadPanelBar1_ItemClick(object sender, RadPanelBarEventArgs e)
       {
           Response.Redirect(e.Item.Attributes["CustomNavigateUrl"].ToString()); 
       }


    Regards,
    Nencho
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017