2

Let's say I want to show a fieldset that contains a form and a button.

There will be some textboxes for I/O values and some labels for:

  1. the fieldset title (not related to values)
  2. textboxes (labels and validations)
  3. the submit button (not related to values)

The labels will be provided from a database based on localization.

For case 2 I would like to use the mechanisms for which mvc already has support (DataAnnotations attributes) so I have found the following 2 solutions:

A view model example would be something like this:

Model
{
    fieldset title localized label

    [textbox localized display label]
    [textbox localized validation label]
    textbox value

    button localized label
}

While the labels for case 2 are specified as meta-data for the view model values, what would be an elegant and consistent way for specifying localized texts from a database for case 1 and 3 considering a view with a big content?

Community
  • 1
  • 1
Dan
  • 1,555
  • 2
  • 14
  • 30

1 Answers1

0

A solution, although overkill, would be to have an empty model member with a display attribute for each localized label and to use a custom helper[1] to retrieve the plain text.

[1]: Get DisplayName Attribute without using LabelFor Helper in asp.net MVC

Community
  • 1
  • 1
Dan
  • 1,555
  • 2
  • 14
  • 30