G
Guest
in .net 2.0, the class (myClass) contains a property defined as:
private _creationDate as As Nullable(Of DateTime)
Public Property CreationDate() As Nullable(Of DateTime)
Get
If _creationDate.HasValue Then
Return _creationDate
Else
Return Nothing
End If
End Get
Set(ByVal value As Nullable(Of DateTime))
If value.HasValue Then _creationDate= value
End Set
End Property
when I call this property on the aspx page to assign its value to a text
field as:
<input type=text id=myText ... .. ..>
.....
.... .. ..
myText.value = myCylass.CreationDate
it return "Nullable object must have a value", unless I test for the NULL
value as:
if CreationDate.HasValue then myText.value= CreationDate (will work)
I don't understand why the property cannot return NULL when its return type
is set as (Nullable of DateTime).
private _creationDate as As Nullable(Of DateTime)
Public Property CreationDate() As Nullable(Of DateTime)
Get
If _creationDate.HasValue Then
Return _creationDate
Else
Return Nothing
End If
End Get
Set(ByVal value As Nullable(Of DateTime))
If value.HasValue Then _creationDate= value
End Set
End Property
when I call this property on the aspx page to assign its value to a text
field as:
<input type=text id=myText ... .. ..>
.....
.... .. ..
myText.value = myCylass.CreationDate
it return "Nullable object must have a value", unless I test for the NULL
value as:
if CreationDate.HasValue then myText.value= CreationDate (will work)
I don't understand why the property cannot return NULL when its return type
is set as (Nullable of DateTime).