Automatic Marking of Required Fields with EditorEntryFor

Using an EditorEntryFor helper makes the code DRYer and opens new possibilities, such as automatic indication of required fields. A small addition in one helper method will mark all required fields in entire MVC web application. It’s more or less standard to indicate required fields in a form with a red * next to the… Continue reading Automatic Marking of Required Fields with EditorEntryFor

DRYing MVC Forms with an EditorEntryFor Helper

When creating forms in ASP.NET MVC I use a small helper to keep the code DRY (Don’t Repeat Yourself). The EditorEntryFor helper creates everything needed for a form field – the label, the input and the validation. When creating line of business applications, a huge part of the coding is often to create forms. Each… Continue reading DRYing MVC Forms with an EditorEntryFor Helper

Naming by Purpose or by Effect

What’s the best way to name a css class: form-field-label or bold-text? Is there any difference between MVC’s EditorFor and TextBoxFor? Or between a DetailedRowText property and ArticleDescription? For all the cases, there is a difference. The first one is naming by purpose and the other naming by effect, or what it actually does. Even… Continue reading Naming by Purpose or by Effect

Dissecting MVC Scaffolded Code for EF Updates

MVC and Entity Framework scaffolding is powerful, but I prefer to know what actually happens before accepting generated code. The code generated to update an entity when an edit has been done looked interesting, so I decided to have a closer look at it. When an edit is done to an entity, the data is… Continue reading Dissecting MVC Scaffolded Code for EF Updates