prevent canceling control events
This commit is contained in:
@@ -44,6 +44,8 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
||||
|
||||
#region Properties
|
||||
|
||||
public bool AllowCancelControlEvents { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before a RadControl is being validated.
|
||||
/// </summary>
|
||||
@@ -370,9 +372,8 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
||||
var node = DataUtils.Parse(ruleToEvaluete.Expression, ruleToEvaluete.CaseSensitive);
|
||||
var result = node.Eval(null, context);
|
||||
|
||||
if (result is bool)
|
||||
if (result is bool boolResult)
|
||||
{
|
||||
var boolResult = (bool)result;
|
||||
var validationEventArgs = FireValidationEvent(!boolResult, (RadControl)sender, ruleToEvaluete);
|
||||
if (validationEventArgs.DisplayIconAndToolTip)
|
||||
boolResult = AddOrRemoveImage(validationEventArgs, (RadControl)sender, ruleToEvaluete);
|
||||
@@ -381,8 +382,7 @@ public class RadValidationProviderEx : Component, ISupportInitialize, IExtenderP
|
||||
boolResult = validationEventArgs.IsValid;
|
||||
}
|
||||
|
||||
var cancelEventArgs = e as CancelEventArgs;
|
||||
if (cancelEventArgs != null)
|
||||
if (AllowCancelControlEvents && e is CancelEventArgs cancelEventArgs)
|
||||
cancelEventArgs.Cancel = !boolResult;
|
||||
|
||||
if (!boolResult)
|
||||
|
||||
Reference in New Issue
Block a user