Here is a CallbackValidationRole example form that validates whether a checkbox is checked:
Path on our test web: Root-> Mike’s World -> Customers (Mike) -> CallbackValidation_CheckBox
The form maps eForm‘s event Loaded:
Code:
using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; using System.Xml.Linq; using Neurodot.Forms.Controls; using Neurodot.Forms.CustomControls.RadioGroup; using Neurodot.Forms.Render; using Neurodot.Forms.Render.Interfaces; public static partial class FormCodeClass { // To find controls in the current visual tree (i.e. the form) use static methods: // object ThisForm.FindElement(string elementName); or // T ThisForm.FindElement<T>(string elementName); static CheckBox _checkBox = ThisForm.FindElement<CheckBox>("CheckBoxConfirm"); public static void Loaded(object sender, System.Windows.RoutedEventArgs e) { var role = new CallbackValidationRole("$CheckValidationMessage") { Callback = ValidateConfirmCheckBox }; ThisForm.RegisterValidationRole(_checkBox, role); } // Validates if the checkbox is checked. // Returns true if the checkbox is checked (valid); otherwise, false (invalid). private static bool ValidateConfirmCheckBox() { return (_checkBox.IsChecked == true); } }