Basically, I have a text box that needs only decimal entries, but a validation rule that only allow decimals inside this text box.
Here is the code I have, but it does not do what I want:
#Region " RULE: Decimal Value Required Rule "
Public Class DecimalRequiredRule
Inherits Rules.BusinessRule
Public Sub New(ByVal primaryProperty As Core.IPropertyInfo)
InputProperties = New List(Of IPropertyInfo)({primaryProperty})
Me.PrimaryProperty = primaryProperty
End Sub
Protected Overrides Sub Execute(ByVal context As Csla.Rules.RuleContext)
Try
Dim isDecimal As Decimal = CDec(context.InputPropertyValues(PrimaryProperty))
Catch ex As Exception
context.AddErrorResult(PrimaryProperty.FriendlyName & " must be a decimal")
End Try
End Sub
End Class
#End Region