Back to Devexpress

ASPxRibbon Class

aspnet-devexpress-dot-web-17ae532a.md

latest16.3 KB
Original Source

ASPxRibbon Class

A ribbon control.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class ASPxRibbon :
    ASPxHierarchicalDataWebControl,
    IParentSkinOwner,
    ISkinOwner,
    IPropertiesOwner,
    IControlDesigner,
    IRequiresLoadPostDataControl,
    IRibbonBarOwner
vb
Public Class ASPxRibbon
    Inherits ASPxHierarchicalDataWebControl
    Implements IParentSkinOwner,
               ISkinOwner,
               IPropertiesOwner,
               IControlDesigner,
               IRequiresLoadPostDataControl,
               IRibbonBarOwner

The following members return ASPxRibbon objects:

Remarks

The ASPxRibbon is a tabbed toolbar that allows you to place command items on several tabs.

Create a Ribbon

Design Time

The ASPxRibbon control is available on the DX.25.2: Navigation & Layout toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control’s settings, or paste the control markup in the page’s source code.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" runat="server">
    <Tabs>
        <dx:RibbonTab Name="Home" Text="Home" />
        <dx:RibbonTab Name="Insert" Text="Insert" />
    </Tabs>
</dx:ASPxRibbon>

Run Time

csharp
using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e) {
    ASPxRibbon ribbon = new ASPxRibbon();
    ribbon.ID = "ASPxRibbon1";

    RibbonTab tab1 = new RibbonTab("Home");
    RibbonTab tab2 = new RibbonTab("Insert");
    ribbon.Tabs.Add(tab1);
    ribbon.Tabs.Add(tab2);

    // Adds the created control to the page
     Page.Form.Controls.Add(ribbon1);
}
vb
Imports DevExpress.Web
...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim ribbon As ASPxRibbon = New ASPxRibbon()
    ribbon.ID = "ASPxRibbon1"

    Dim tab1 As RibbonTab = New RibbonTab("Home")
    Dim tab2 As RibbonTab = New RibbonTab("Insert")
    ribbon.Tabs.Add(tab1)
    ribbon.Tabs.Add(tab2)

    ' Adds the created control to the page
    Page.Form.Controls.Add(ribbon1)
End Sub

Note

DevExpress controls require that you register special modules, handlers, and options in the Web.config file. You can change this file or switch to the Design tab in the Microsoft Visual Studio IDE to automatically update the Web.config file. Note that this information is automatically registered if you use the DevExpress Template Gallery to create a project.

Client-Side API

The ASPxRibbon ‘s client-side API is implemented with JavaScript language and exposed by the ASPxClientRibbon object.

|

Availability

|

Available by default.

| |

Client object type

|

ASPxClientRibbon

| |

Access name

|

ASPxRibbon.ClientInstanceName

| |

Events

|

ASPxRibbon.ClientSideEvents

|

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" runat="server" ClientInstanceName="ribbon">
    //...
</dx:ASPxRibbon>
js
function buttonClick(){
    // Makes a tab with the specified index active.
    ribbon.SetActiveTabIndex(2);
}

Common Concept

The ribbon stores a set of tabs (RibbonTab) in the Tabs collection. You can specify an individual tab’s header text (Text), name (Name) and the visibility (Visible).

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ...>
    <Tabs>
        <dx:RibbonTab Name="Home" Text="Home" />
        <dx:RibbonTab Name="Insert" Text="Insert" Visible="False" />
    </Tabs>
</dx:ASPxRibbon>

To hide all tab headers, set the ASPxRibbon.ShowTabs property to false.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ShowTabs="False" >
</dx:ASPxRibbon>

The “File” tab is the first tab in the ribbon’s header. Its visibility depends on the ASPxRibbon.ShowFileTab property value. Note that the ribbon does not store the “File” tab in the tab collection (RibbonTabCollection).

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" runat="server" ShowFileTab="False" >
</dx:ASPxRibbon>

A tab (RibbonTab) contains groups (RibbonGroup) with items (RibbonItemBase). You can use the RibbonTab.Groups and RibbonGroup.Items properties to access groups and group items in a tab.

Use the RibbonGroup.Text property to specify a group’s label. To hide all group labels in the ribbon, set the ASPxRibbon.ShowGroupLabels property to false.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ShowGroupLabels="False" ...>
    <Tabs>
        <dx:RibbonTab Name="Home" Text="Home">
            <Groups>
                <dx:RibbonGroup Name="Clipboard" Text="Clipboard">
                    <Items>
                        <dx:RibbonButtonItem Name="Cut" Text="Cut" />
                        <dx:RibbonButtonItem Name="Copy" Text="Copy" />
                    </Items>
                </dx:RibbonGroup>
            </Groups>
        </dx:RibbonTab>
    </Tabs>
</dx:ASPxRibbon>

Data Binding

Use the ASPxHierarchicalDataWebControl.DataSourceID or ASPxDataWebControlBase.DataSource property to bind the ribbon to a data source.

aspx
<dx:ASPxRibbon ID="Ribbon" runat="server" DataSourceID="RibbonDataSource" />

Mappings specify which field in a data source corresponds to an object’s property.

|

Object

|

Mappings

| | --- | --- | |

Tab

|

ASPxRibbon.TabDataFields

| |

Group

|

ASPxRibbon.GroupDataFields

| |

Item

|

ASPxRibbon.ItemDataFields

|

More details | See demo

Item Types

The ribbon allows you to use different editors as items (button, text box, combo box and others).

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ShowGroupLabels="False" ...>
    <Tabs>
        <dx:RibbonTab Name="Home" Text="Home">
            <Groups>
                <dx:RibbonGroup Name="Clipboard" Text="Clipboard">
                    <Items>
                        <dx:RibbonButtonItem Name="Cut" Text="Cut" />
                        <dx:RibbonComboBoxItem Name="Font Family">
                            // ...
                        </dx:RibbonComboBoxItem>
                    </Items>
                </dx:RibbonGroup>
            </Groups>
        </dx:RibbonTab>
    </Tabs>
</dx:ASPxRibbon>

More details

The ribbon provides a gallery bar (RibbonGalleryBarItem) and drop-down gallery (RibbonGalleryDropDownItem) items to display image lists in the ribbon.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ShowGroupLabels="False" ...>
    <Tabs>
        <dx:RibbonTab Text="Home">
            <Groups>
                <dx:RibbonGroup Text="Font">
                    <Items>
                        <!-- Gallery Bar -->
                        <dx:RibbonGalleryBarItem >
                            <Groups>
                                <dx:RibbonGalleryGroup>
                                    <Items>
                                        ...
                                    </Items>
                                </dx:RibbonGalleryGroup>
                            </Groups>
                        </dx:RibbonGalleryBarItem>

                        <!-- Drop-Down Gallery -->
                        <dx:RibbonGalleryDropDownItem >
                            <Groups>
                                <dx:RibbonGalleryGroup>
                                    <Items>
                                        ...
                                    </Items>
                                </dx:RibbonGalleryGroup>
                            </Groups>
                        </dx:RibbonGalleryDropDownItem>
                    </Items>
                </dx:RibbonGroup>
            </Groups>
        </dx:RibbonTab>
    </Tabs>
</dx:ASPxRibbon>

More details | See demo

Context Tabs

The ribbon supports context tabs (RibbonContextTabCategory) and stores them in the ContextTabCategories collection.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" ShowGroupLabels="False" ...>
    <Tabs>
        ...
    </Tabs>
    <ContextTabCategories>
        <dx:RibbonContextTabCategory Name="Table tools" ...>
            <Tabs>
                <dx:RibbonTab Text="Design" />
                ...
            </Tabs>
        </dx:RibbonContextTabCategory>
    </ContextTabCategories>    
</dx:ASPxRibbon>

See demo

Templates

You can provide custom content for the ribbon’s elements: file tab (FileTabTemplate) and item (Template).

aspx
<dx:ASPxRibbon ID="Ribbon" >
    <Tabs>
        <dx:RibbonTab Text="Search">
            <Groups>
                <dx:RibbonGroup Text="">
                    <Items>
                        <dx:RibbonTemplateItem Size="Large">
                            <Template>
                                <table><tr>
                                    <td>
                                        <dx:ASPxTextBox ID="SearchTextBox" />
                                    </td>
                                    <td>
                                        <dx:ASPxButton ID="SearchButton" />
                                    </td>
                                </tr></table>
                                <dx:ASPxCheckBoxList runat="server" >
                                    <Items>
                                        <dx:ListEditItem Text="User tickets" />
                                        <dx:ListEditItem Text="Documentation" />
                                        <dx:ListEditItem Text="What's new" />
                                        <dx:ListEditItem Text="Code examples" />
                                    </Items>
                                </dx:ASPxCheckBoxList>
                            </Template>
                        </dx:RibbonTemplateItem>
                    </Items>
                </dx:RibbonGroup>
            </Groups>
        </dx:RibbonTab>
    </Tabs>
</dx:ASPxRibbon>

See demo

One-Line Mode

The ribbon can display all items within an active tab in one line (OneLineMode), which makes the ribbon look more compact.

aspx
<dx:ASPxRibbon ID="ASPxRibbon1" OneLineMode="true" ...>
</dx:ASPxRibbon>

See demo

Implements

Show 15 items

IComponent

IDisposable

IParserAccessor

IDataBindingsAccessor

IControlBuilderAccessor

IControlDesignerAccessor

IExpressionsAccessor

IAttributeAccessor

IUrlResolutionService

INamingContainer

IPostBackDataHandler

IPostBackEventHandler

ICallbackEventHandler

IDataSourceViewSchemaAccessor

IPropertiesOwner

Inheritance

Object Control WebControl ASPxWebControlBase ASPxWebControl ASPxDataWebControlBase ASPxHierarchicalDataWebControl ASPxRibbon BootstrapRibbon

MVCxRibbon

See Also

ASPxRibbon Members

Ribbon

DevExpress.Web Namespace