RuleSeverity Question

RuleSeverity Question

Old forum URL: forums.lhotka.net/forums/t/5003.aspx


IanK posted on Sunday, June 22, 2008

In relaxing some rules from validation.RuleServerity.Error to Validation.RuleSeverity.Warning I notice that as expected my object's IsValid property becomes true even though there are warnings with associated with the obect but the ErrorProvider on the form no longer displays errors (now warnings) against the associated bound controls.

Is there any way to reduce  the severity on rules to warnings or information level but still give the user some visual representation of this without resorting to testing for warnings and displaying them only when save button is hit.  I was expecting the errorProvider to behave the same as the return in the rules are still returning true for an error and setting the description.

Sample rule:

Private Shared Function VerifyAreaCode(Of T As BTier.Site)(ByVal target As Object, ByVal e As Validation.RuleArgs) As Boolean

If target.conareacode.ToString.Length = 0 Then

   e.Description = "Area codes are needed to Auto-Create Juxta Records!"

   e.Severity = Validation.RuleSeverity.Warning

   Return False

Else

   Return True

End If

End Function

 

JonnyBee replied on Sunday, June 22, 2008

Hi,

Chect out the posts in this thread.
http://forums.lhotka.net/forums/thread/18083.aspx
The standard ErrorProvider in .Net does only know about Error.

/jonny

IanK replied on Sunday, June 22, 2008

Thanks Jonny,

ErrorWarnInfoProvider referenced by thread was exactly what I was looking for.

Copyright (c) Marimer LLC