0

I try tovalidate two dates (start -> end) where only the first ist required, but when the user enters the second date it must be greater than the first. I'm using the MVC Foolproof package with the "PassOnNull" parameter.

Model

<Required()> _
<DisplayName("Event Start")> _
<DataType(DataType.DateTime)> _
'This doesn't work:
Public Property EventStart As Nullable(Of DateTime)
'This does work but with the ugly default value in the textbox
Public Property EventStart As DateTime

<DisplayName("Event End")> _
<DataType(DataType.DateTime)> _
<GreaterThan("EventStart", PassOnNull:=True)> _
Public Property EventEnd As Nullable(Of DateTime)

I can get it to work with setting the EventStart date not NOT nullable but then i get a default date in the textbox with the value "01.01.0001 00:00:00" which is'nt even my country setting!

So I would like to get it to work with the nullable model propery or get rid of the "01.01.0001 00:00:00" value and have a blank textboy instead!

4

1 に答える 1

1

Codeplex でhttp://foolproof.codeplex.com/discussions/220498を読んだ後、逆に機能することがわかりました。

<Required()> _
<DisplayName("Event Start")> _
<LessThan("EventEnd", PassOnNull:=True)> _
Public Property EventStart As Nullable(Of DateTime)

<DisplayName("Event End")> _
Public Property EventEnd As Nullable(Of DateTime)
于 2012-09-17T07:14:44.970 に答える