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

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