S
shapper
Hello,
I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:
' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property ' Validation
Validation is class with various properties under the namespace
MyNameSpace:
' Validation
Public Class Validation
' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property ' IsRequired
..............
End Class
I am using my control in a page as follows:
Dim a As New MyControl
MyControl.Property1 = "Something"
MyControl.Property2 = True
It works!
When I add the following property:
MyControl.Validation.IsRequired = False
I get the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
On code line:
MyControl.Validation.IsRequired = False
What am I doing wrong?
Thanks,
Miguel
I have a custom control under namespace MyNameSpace.WebControls with a
property of type validation:
' Validation
Private _Validation As Validation
< _
Bindable(True), _
Category("Behavior"), _
DefaultValue(""), _
Localizable(True) _
Public Property Validation() As Validation
Get
Return _Validation
End Get
Set(ByVal value As Validation)
_Validation = value
End Set
End Property ' Validation
Validation is class with various properties under the namespace
MyNameSpace:
' Validation
Public Class Validation
' IsRequired
Private _IsRequired As Boolean
Public Property IsRequired() As Boolean
Get
If _IsRequired = Nothing Then
_IsRequired = False
End If
Return _IsRequired
End Get
Set(ByVal value As Boolean)
_IsRequired = value
End Set
End Property ' IsRequired
..............
End Class
I am using my control in a page as follows:
Dim a As New MyControl
MyControl.Property1 = "Something"
MyControl.Property2 = True
It works!
When I add the following property:
MyControl.Validation.IsRequired = False
I get the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
On code line:
MyControl.Validation.IsRequired = False
What am I doing wrong?
Thanks,
Miguel