Back to Devexpress

Label

aspnet-8989-aspnet-mvc-extensions-data-editors-extensions-label.md

latest2.3 KB
Original Source

Label

  • Aug 08, 2019
  • 2 minutes to read

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):

csharp
<% 
    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):

csharp
@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.

Main Features

  • Ability to Associate a Label to an Extension

  • Appearance Customization

  • Full-Featured Client-Side API