All docs
V18.2
20.2 (EAP/Beta)
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
18.1
17.2

Overview - Label

Label is a label extension that allows you to display text on a web page.

Implementation Details

Label is a LabelExtension class instance . The ExtensionsFactory.Label helper method allows you to add a Label extension to a view. This method's parameter provides access to the Label's settings (LabelSettings).

The ASPxClientLabel object is a Label's client counterpart.

NOTE

Use the Overview - LabelFor extension to specify a label element's for attribute.

Declaration

The following code snippets illustrate how to add a Label to a view:

View code (ASPX):

<% 
    Html.DevExpress().Label(
        settings => {
            settings.Name = "label1";
            settings.Text = "Some text";
            settings.Properties.EnableClientSideAPI = true;
        }
    )
    .Render();
%> 


<% 
    Html.DevExpress().Button(
        settings => {
            settings.Name = "myButton1";
            settings.ClientSideEvents.Click = "function (s, e) {label1.SetText(label1.GetText() + ' New text');}";
        }
    )
    .Render();
%> 

View code (Razor):

@Html.DevExpress().Label(
    settings => {
        settings.Name = "label1";
        settings.Text = "Some text";
        settings.Properties.EnableClientSideAPI = true;
    }).GetHtml()


@Html.DevExpress().Button(
    settings => {
        settings.Name = "myButton1";
        settings.ClientSideEvents.Click = "function (s, e) {label1.SetText(label1.GetText() + ' New text');}";
    }).GetHtml()
NOTE

The Partial View should contain only the extension's code.

The image below shows the result.

label-declaration.png

See Also