G
Guest
I converted the C# code from 4guysfromrolla into vb.net. When i try to
compile it, i get the following error:
A namespace does not directly contain members such as fields or methods
Here is the code i have:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Namespace customValidators
Public Class RequiredFieldValidatorForCheckBoxLists
Inherits System.Web.UI.WebControls.BaseValidator
Private _listctrl As ListControl
Public Sub RequiredFieldValidatorForCheckBoxLists()
EnableClientScript = False
End Sub
Protected Overrides Function ControlPropertiesValid() As Boolean
Dim ctrl As Control
ctrl = FindControl(ControlToValidate)
If Not (ctrl Is Nothing) Then
_listctrl = CType(ctrl, ListControl)
Return Not (_listctrl Is Nothing)
Else
Return False
End If
End Function
Protected Overrides Function EvaluateIsValid() As Boolean
Return _listctrl.SelectedIndex <> -1
End Function
End Class
End Namespace
Can someone please tell me what is the problem with it?
Thanks
Manny
compile it, i get the following error:
A namespace does not directly contain members such as fields or methods
Here is the code i have:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Namespace customValidators
Public Class RequiredFieldValidatorForCheckBoxLists
Inherits System.Web.UI.WebControls.BaseValidator
Private _listctrl As ListControl
Public Sub RequiredFieldValidatorForCheckBoxLists()
EnableClientScript = False
End Sub
Protected Overrides Function ControlPropertiesValid() As Boolean
Dim ctrl As Control
ctrl = FindControl(ControlToValidate)
If Not (ctrl Is Nothing) Then
_listctrl = CType(ctrl, ListControl)
Return Not (_listctrl Is Nothing)
Else
Return False
End If
End Function
Protected Overrides Function EvaluateIsValid() As Boolean
Return _listctrl.SelectedIndex <> -1
End Function
End Class
End Namespace
Can someone please tell me what is the problem with it?
Thanks
Manny