views:

123

answers:

1

Hi, i'm using Linq to SQL for my model with a custom validation layer. I cannot find the way to edit or change the default message:

The value '29/34/1980' is not valid for BirthDate.

BirthDate is of course my textbox. Any ideas? Thanks

EDIT: this is the simple code i'm using:

<%= Html.Label("Data di Nascita (GG/MM/AAAA)", "BirthDate")%>
<%= Html.TextBox("BirthDate", Model.BirthDate) %>
<%= Html.ValidationMessage("BirthDate", " *") %>

and this is the validation code, that does not override the default message:

if (!(person.BirthDate > DateTime.MinValue)) // Diverso dal default
    _validation.AddError("BirthDate", "Il campo 'Data di nascita' non è valido");
A: 

Did you use a DateTimePicker for your TextBox? Try specifying a format like "yyyy-MM-dd" for it and Parse the string to a DateTime first.

Benedict
no date picker, just the textbox of a strongly typed View with the model property "BirthDate" as value. No chance to parse or try parse... mvc framework is taking it first...
Gremo