Skip to main content

Editors, Buttons, Validation, and Feedback

This example is the Editors section hosts a CustomerEditor UserControl — six value-matched editors with a Label each, one ErrorProvider driven by four named validators, a ToolTip per editor, Save / Reset / Validate with a busy state, and Toast / AlertBox feedback. One MessageBox remains, for the only real decision (discarding unsaved changes).

The shell and the other five placeholders come from Module 1. This module fills Sections/EditorsPage and adds Editors/, three models and Services/CustomerService.cs.

Run it

cd "LearnWisej-Samples/Mastering the Control Library Course/Module 2/OperationsConsole"
dotnet run -f net10.0 --urls http://localhost:5702

Then open http://localhost:5702 and click Editors.

What to try

ActionWhat you should see
Hover a fieldthe ToolTip says what the field expects
Fill in a valid customer (status Active, credit limit ≥ 1,000), ValidateToast "Validation passed: all six fields are valid.", green status
Savethe three commands grey out, the loader spins on Save and "Saving…" shows for ~1.2 s, then Toast "Customer … saved as CUS-0001.", diagnostics Record: CUS-0001
Clear the name, press Tabred mark beside txtName; you are not trapped in the field
Type orders.acme in Email, press Tabred mark with the email-shape message; fix it and it clears
Status Active, credit limit 500, Savecredit-limit message; switch to Prospect and the mark clears
Status Active, start date next month, Savestart-date message
Tick Simulate service failure, Save a valid customerbusy state, then a red AlertBox and red status; nothing is saved. Untick and save again to recover
Change a field, ResetMessageBox "Discard the changes …?" — No keeps your typing, Yes restores the last saved values

Where things live

OperationsConsole/
├─ Editors/CustomerEditor.cs / .Designer.cs the editor: validators, SaveAsync, Reset, busy state, feedback
├─ Sections/EditorsPage.cs / .Designer.cs hosts customerEditor + the Simulate service failure switch
├─ Models/CustomerModel.cs, OptionItem.cs, ValidationResult.cs
├─ Services/CustomerService.cs in-memory store, CUS-000N ids, latency, SimulateFailure, ValidateForSave
└─ docs/EditorDecisions.md deliverable: editor per field, validation layers, feedback channels

Known simplifications

  • CustomerService is in memory and per session; ids restart at CUS-0001 for every session.
  • Busy feedback is btnSave.ShowLoader plus a "Saving…" label: ProgressBar in Wisej.NET 4.1 has no marquee style.