Skip to main content
A newer version of this page is available. .
Tab

ASPxNavBar.AutoCollapse Property

Gets or sets a value specifying whether only one group can be expanded at a time within the NavBar.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

[DefaultValue(false)]
public bool AutoCollapse { get; set; }

Property Value

Type Default Description
Boolean **false**

true if only one group can be expanded within the navbar control; false if the navbar can have multiple groups expanded simultaneously.

Remarks

Use the AutoCollapse property to control the ability of the navbar control to automatically collapse any previously expanded group when an end-user expands a new group.

End users are able to expand groups by clicking on the group expand button button or group header. If the AutoCollapse property is set to false (the default behavior) end users can expand several groups within the navbar control.

Set the AutoCollapse property to true to apply the auto collapse feature to the navbar control, thus forcing it to have only one group expanded at a time. In this instance, expanding a group collapses any other expanded group within the navbar. Note that the expanded group cannot be collapsed either by the end-user interface or programmatically. This can only be achieved by expanding another group.

Applying the auto collapse feature to a navbar control that has several groups currently expanded sets the first group from the ASPxNavBar.Groups collection to the expanded state and closes any other group.

Example

The example demonstrates how to create the ASPxNavBar groups and items at runtime to create a FAQ page.

Data can be obtained from any type of a datasource. For example, the data can be obtained from the Access database file using the OLE DB provider.The sample was built from the kindly provided How to use the ASPxNavBar with an Access or SQL datasource suggestion article, containing the URL to the tutorial video file.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxNavBar" TagPrefix="dx" %>

<!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 id="Head1" runat="server">
    <title>How to create the FAQ Page using the ASPxNavBar</title>
    <style type="text/css">
        .heading {
            font-size: large;
            color: Blue;
        }

        .Question {
            color: Gray;
            font-size: 11pt;
        }

            .Question img {
                vertical-align: middle;
            }

            .Question span {
                vertical-align: middle !important;
            }

        .Answer {
            font-size: 11pt;
            padding-left: 35px !important;
            padding-top: 8px;
            padding-bottom: 8px;
        }

        .defaultStyle {
            padding-left: 0px;
            list-style-type: none;
            margin: 0px;
        }
        .groupPadding {
            padding-left:0px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div style="min-height: 500px;">
            <div class="heading">
                Frequently Asked Questions
            </div>
            <div style="padding-left: 10px; padding-top: 10px;">
                <dx:ASPxNavBar ID="navFAQ" runat="server" ExpandButtonPosition="Left"
                    AutoCollapse="True" GroupSpacing="5px" EncodeHtml="False" CssPostfix="None" CssClass="defaultStyle">
                    <GroupHeaderStyle CssClass="Question" ImageSpacing="8px">
                    </GroupHeaderStyle>
                    <CollapseImage Url="~/Images/nbCollapse.png">
                    </CollapseImage>
                    <ExpandImage Url="~/Images/nbExpand.png">
                    </ExpandImage>
                    <ItemStyle CssClass="Answer defaultStyle" />
                    <GroupContentStyle CssClass="groupPadding"></GroupContentStyle>
                </dx:ASPxNavBar>
            </div>
        </div>
    </form>
</body>
</html>
See Also