title: MVC 2 Templates - Is it possible to redirect the current editor template to its display template based on metadata?
body: <p>For a project I'm working I've been asked to redirect an editor template to its display template based on metadata that is provided with the model.</p>
  
  <p>Now I was looking at a way to do it before it hits the editor template but that seems to cause more issues than it is worth, at least with how the system has been architected.</p>
  
  <p>The simplest example is the string editor, its a simple textbox but if IsReadOnly is set we want it to only show up as text, not a disabled textbox.</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %&gt;
  &lt;%
      if (this.ViewData.ModelMetadata.IsReadOnly)
      {
          Response.Write(Html.DisplayForModel());
      }
      else if (this.ViewData.ModelMetadata.ShowForEdit)
      {
  &lt;%= Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { @class = "text-box single-line" }) %&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>So far the only real solution I can find is to copy the display template into the editor template.  Does anyone have any ideas how I can do something that will work without replicating more code?</p>