HTML and CSS Reference
In-Depth Information
{
attributes.Add("readonly", "readonly");
}
if (ViewData.ModelMetadata.IsRequired)
{
attributes.Add("required", "required");
}
}
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, attributes)
10. Press F5 to debug the application and navigate to the Feedback page, which should
look like Figure 3-17 .
Figure 3-17. The feedback page using third-party templates
Adding Literal HTML
Using the Html helper class, including the EditorFor() method is the recommended way to implement forms
with ASP.NET MVC. This provides tight integration with the model including the model metadata and the
separation of concerns (business rules and user experience). However, you can always embed the actual HTML
markup in your view. An appropriate use of this would be to include static content or a control that is not
connected to a model, such as a progress bar.
I'll now demonstrate three examples of inserting one of the new HTML5 control into the feedback form
using direct HTML markup:
Range
Progress
Meter
 
Search WWH ::




Custom Search