aspnet-14721-aspnet-mvc-extensions-common-concepts-templates.md
Templates allow you to quickly extend built-in functionality and introduce new capabilities with minimum effort. The DevExpress MVC extensions provide you with the ability to create templates for various extension elements.
Templates can be defined at different object levels at the same time (e.g., at the extension level and the item level). In this case, templates created at a lower level in the logical tree take precedence over other templates for the same element created at a higher level (e.g., a template defined at the item level has precedence over the same element template created at the extension level).
The Set_ElementName_TemplateContent methods are provided to define an element template.
For each template type you want to use, create a Partial View (a .cshtml or .vbhtml) and provide it with the required content markup. To use this Partial View within a template, call the Html.RenderPartial helper method in template implementation.
Note that the method delegates that enable you to implement templates give you access to a container object within which a template is instantiated. A template container object typically exposes useful information identifying the templated element (for instance, for a grid column header these might be the corresponding column, the header’s current location - in the header section, Group Panel, or Customization Window, etc.). Depending upon your application logic, you may or may not use this information when composing templates. The following options are available.
Without Passing a Template Container
Passing a Template Container as a Model to a Partial View
Passing Template Container via ViewData
If you do not want to use partial views for some reason, and need to entirely define template contents within a delegate method implementation, you can do this using the following options.
Using DevExpress extensions as child controls
Using ViewContext.Writer.Write
Using HtmlHelper class