Format a Form Generated by EditorForModel

If MVVM pattern is used, a data entry form (e.g. email form) can be generated with a simple statement - EditoForModel (Model).

Usually, the format of the output is not exactly what one wishes.  Formatting is often necessary. The orthodox way of doing this is using an editor template.  This is the best way to go about it if the format is used in many places. If all one wants is something like setting the height of a text area for a particular page. One could achieve this by one statement of jQuery like the following:

$("#VariableName").attr("style", "height:400px;")

VariableName is the name of the corresponding variable of the ViewModel.

This article was updated on 01:12:38 2024-03-24