HTML and CSS Reference
In-Depth Information
<div class="editor-label">
@Html.LabelFor(m => m.Satisfaction)
</div>
<div class="editor-field">
@Html.EditorFor(m => m.Satisfaction)
</div>
<p>
<input type="submit" value="Submit" />
</p>
2.
save your changes and press F5 to view the modified form. Click the Feedback link
to display the page, which will look similar to Figure 3-11 .
Figure 3-11. The feedback form
3.
notice that all the new fields use the standard Textbox control and do not include a
placeholder text. This is because there is no editor template defined for these data types.
Adding Editor Templates
You may have been asking yourself, how does the framework know which template to use? The framework tries to
use the correct template based on the data type of the property. This is not very reliable as e-mail, urls, and phone
numbers are all stored in a string variable. The preferred method is to define this using metadata.
If you include the System.ComponentModel.DataAnnotations namespace in your model class you can
include metadata in your model. There are two metadata attributes that are used to determine the appropriate
template:
DataType
UIHint
 
Search WWH ::




Custom Search