title: If else logic in Razor DisplayFor vs TextBoxFor MVC4
body: <p>If a certain variable is set I want a certain field to be a textbox, if it is not I want that field to simply display the value but that value is not editable.</p>
  
  <p>I put some if else logic into my views and the value won't display.  Am I missing something here?</p>
  
  <pre><code>            @{
                  if (isFlagSet) {
                      Html.TextBoxFor(m =&gt; m.HostpitalFinNumber, new { @Value = Model.HostpitalFinNumber });
                      Html.ValidationMessageFor(m =&gt; m.HostpitalFinNumber);
                  }
                  else {
                      Html.DisplayTextFor(m =&gt; m.HostpitalFinNumber);
                  }
              }
  </code></pre>
  
  <p>Update...</p>
  
  <p>I changed my code to </p>
  
  <pre><code>            @if (isFlagSet) {
                      Html.TextBoxFor(m =&gt; m.HostpitalFinNumber);
                      Html.ValidationMessageFor(m =&gt; m.HostpitalFinNumber);
              }
              else {
                      Html.DisplayFor(m =&gt; m.HostpitalFinNumber);
              }
  </code></pre>
  
  <p>The following is the HTML being generated.  Notice how an input value is being written for Phone but not hospital fin.  Hot sure why that is happening.         </p>
  
  <pre><code>    &lt;tr&gt;&lt;td&gt;
          &lt;label for="Phone"&gt;Phone&lt;/label&gt;
          &lt;/td&gt;
          &lt;td&gt;
          &lt;input Value="4124880798" id="Phone" name="Phone" type="text" value="4124880798" /&gt;
      &lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
          &lt;label for="HostpitalFinNumber"&gt;HostpitalFinNumber&lt;/label&gt;              
          &lt;/td&gt;
          &lt;td&gt;
  
      &lt;/td&gt;&lt;/tr&gt;
  </code></pre>
  
  <p>ANSWER </p>
  
  <p>I forgot to put the @ in front of my html helper and get rid of the Semi-colons.</p>