How To: RadPanelBar Expand From Code Behind

3 posts, 0 answers
  1. Mark
    Mark avatar
    25 posts
    Member since:
    Feb 2012

    Posted 21 Mar 2013 Link to this post

    Hi, I have a Panel Bar on a page that will display different errors for different reasons (from a query string).
    I want to tell the Panel Bar (On Page Load - a protected void will be called) to Expand or Enable certain RadPanelItem(s).

    Code Behind:
    protected void LoadPanelItems()
    {
        RadPanelItem expired = rdPnlStatusError.FindItemByValue("ExpiredPassword");
        RadPanelItem locked = rdPnlStatusError.FindItemByValue("AccountLocked");
        RadPanelItem invalid = rdPnlStatusError.FindItemByValue("InvalidLogin");
        RadPanelItem forgot = rdPnlStatusError.FindItemByValue("ForgotPassword");
         
        var errCode = GetError(Request.QueryString["eCode"]);
        switch (errCode)
        {
            case "ValidExpired":
                expired.Expanded = true;
                locked.Enabled = false;
                invalid.Enabled = false;
                forgot.Enabled = false;
                break;
            case "AccountLocked":
                locked.Expanded = true;
                expired.Enabled = false;
                invalid.Enabled = false;
                forgot.Enabled = false;
                break;
            case "Invalid":
                invalid.Expanded = true;
                locked.Enabled = false;
                expired.Enabled = false;
                forgot.Enabled = false;
                break;
            case "ForgotPassword":
                forgot.Expanded=true;
                invalid.Enabled = false;
                locked.Enabled = false;
                expired.Enabled = false;
                break;
        }

    It doesn't work - is there any way I CAN get that to work?
  2. Mark
    Mark avatar
    25 posts
    Member since:
    Feb 2012

    Posted 22 Mar 2013 Link to this post

    Anything?
    I ran into an issue with them ALL expanding on page load.

    I tried adding this to each RadPanelItem:

    <telerik:RadPanelItem runat="server" Text="Expired Password" Value="ExpiredPassword" Expanded="False" Selected="False">

    But that didn't work.

    I have this, in my main:
    <telerik:RadPanelBar ID="rdPnlStatusError" Width="100%" ExpandMode="SingleExpandedItem" AllowCollapseAllItems="True" runat="server">

    But that doesn't make a difference... any thoughts?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christoph
    Christoph avatar
    1 posts
    Member since:
    Feb 2013

    Posted 27 Mar 2013 Link to this post

    Hi,

    I´m quite new to Telerik and had a similar issue. This works for me:

    protected void Page_Load(object sender, EventArgs e)
        {
            load();
        }
     
        protected void load() {
            RadPanelItem testItem = new RadPanelItem();
            testItem = RadPanelBar1.FindItemByValue( "TestItem" );
     
            var Code = "no";
            switch( Code ) {
                case "yes":
                    testItem.Expanded = true;
                    break;
                case "no":
                    testItem.Expanded = false;
                    break;
            }
        }
    Best regards
    Christoph
Back to Top