NotNullValidator with VAB

Topics: Validation Application Block
Aug 20, 2008 at 2:44 PM

 hi all,

i've got a problem with the NotNullValidator using the enterpriselibrary 4.0

Imports Microsoft.VisualBasic
Imports Microsoft.Practices.EnterpriseLibrary.Validation.Validators

Public Class validation_class

Private _DropDownlist As String

<NotNullValidator(MessageTemplate:="Required Dropdownlist.")> _
Public Property Dropdownlist() As String

Get
Return
_DropDownlist
End Get

Set
(ByVal value As String)
_DropDownlist = value
End Set

End Property

End Class

if the dropdownlist is not selected, it doesn't spit the error

anyone know why this is or how to fix it?
Aug 20, 2008 at 6:00 PM
Hi,

What does the code that invokes the validation look like?

Fernando
Aug 21, 2008 at 11:28 AM
not sure what you mean, please advise
Aug 21, 2008 at 2:02 PM

You've shown the class to which you've added the validation attributes, but not the code that invokes the validation as described in http://msdn.microsoft.com/en-us/library/cc511605.aspx.

Fernando

Aug 21, 2008 at 3:22 PM
Partial Class ServerSideValidation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

                fill_controls()

        End If

        validate_controls()

    End Sub

    Protected Sub btn_Validate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnValidate.Click

         If Page.IsValid Then

            lbl_success.Text = "Validation Success"

        End If

    End Sub

    Sub fill_controls()

        DropDownList1.Items.Insert(0, New ListItem("-Select a Day-", ""))
        DropDownList1.Items.Insert(1, New ListItem("Monday", "Monday"))
        DropDownList1.Items.Insert(2, New ListItem("Tuesday", "Tuesday"))
        DropDownList1.Items.Insert(3, New ListItem("Wednesday", "Wednesday"))

        Page.DataBind()

    End Sub

    Sub validate_controls()

        DDLValidator.ControlToValidate = "DropDownList1"
        DDLValidator.PropertyName = "Dropdownlist"
        DDLValidator.SourceTypeName = "validation_class"
        DDLValidator.SpecificationSource = ValidationSpecificationSource.Both

    End Sub
Aug 21, 2008 at 4:54 PM

What is DDLValidator there?

Fernando

Aug 21, 2008 at 5:30 PM
propertyproxyvalidator
Aug 26, 2008 at 2:16 PM
Hi,

I'm sorry I couldn't get back to you on this yet. Can you log an issue for this including a full repro project?

Regards,
Fernando