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
Tag: ASP.NET MVC3
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
Separating the Read Model
A typical architecture of a .NET web application is to use EF Code First for data access and MVC to render the web pages. The data model in the database is usually (and should be!) normalized. A normalized data model is also great for updates, but when displaying data it is not enough. E.g. in… Continue reading Separating the Read Model