We've inherited an application and have a query on using @Html.DropDownListFor
@Html.DropDownListFor(model => model.SomeLookup.Id
, new SelectList(SomeList, "Id", "Description")
, "-- select --")
The data-val-required attribute by default is set on the rendered control to
data-val-required="The Id field is required."
This overrides any validation scripting.
We are aware that we can set the data_val_required attribute to the message we want like so:
@Html.DropDownListFor(model => model.SomeLookup.Id
, new SelectList(SomeList, "Id", "Description")
, "-- select --"
, new [] { data_val_required="This field is required" })
The problem is there are dozens of dropdowns across multiple pages within the application (and potentially other applications) which we need to set the attribute on. If we forget to to do this, the user gets the default message which they find confusing.
Is it possible to override this default so that wherever this is used, the default message used is "This field is required"?