Using Labels in User Controls

Dynamics AX 2009

When adding text that appears in User Controls, consider using labels so that the text can be more easily localized.

You can use labels from Microsoft Dynamics AX in the markup for a User Control. Add a Label control from the Toolbox to the layout. Set the Text property to the following value, substituting the number of the label that contains the text you want to display.


The text for the label will appear in the layout for the User Control. It will look like the following in the ASP.NET markup.

<asp:Label ID="Label1" runat="server" Text="<%$axlabel:@SYS1234%>"></asp:Label>

Labels from Microsoft Dynamics AX can also be used in code for a User Control. The Labels class in the Microsoft.Dynamics.Framework.Portal.UI namespace provides the GetLabel method. Use this method to retrieve a label value. For example, the following code uses a label to set the text for a button that was added to a User Control.

protected void Page_Init(object sender, EventArgs e)
    // Set the button text to "Administration".
    Button1.Text = Labels.GetLabel("@SYS90142");

Community Additions