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
| Action | What you should see |
|---|---|
| Hover a field | the ToolTip says what the field expects |
| Fill in a valid customer (status Active, credit limit ≥ 1,000), Validate | Toast "Validation passed: all six fields are valid.", green status |
| Save | the 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 Tab | red mark beside txtName; you are not trapped in the field |
Type orders.acme in Email, press Tab | red mark with the email-shape message; fix it and it clears |
| Status Active, credit limit 500, Save | credit-limit message; switch to Prospect and the mark clears |
| Status Active, start date next month, Save | start-date message |
| Tick Simulate service failure, Save a valid customer | busy state, then a red AlertBox and red status; nothing is saved. Untick and save again to recover |
| Change a field, Reset | MessageBox "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
CustomerServiceis in memory and per session; ids restart atCUS-0001for every session.- Busy feedback is
btnSave.ShowLoaderplus a "Saving…" label:ProgressBarin Wisej.NET 4.1 has no marquee style.