title: Adding a search form using a DateTime template
body: <p>In my EditorTemplates, I have DateTime.cshtml - which works find in create/edit/update views:</p>
  
  <pre><code>@model Nullable&lt;System.DateTime&gt; 
  
  @if ( Model.HasValue ) { 
     @Html.TextBox( "" , String.Format( "{0:dd/MM/yyyy}" , Model.Value ) , new  { @class = "datepicker span2" } ) 
  } 
  else { 
     @Html.TextBox( "" , String.Format( "{0:dd/MM/yyyy}" , DateTime.Now ) , new { @class = "datepicker span2" } ) 
  } 
  </code></pre>
  
  <p>When creating a search view, I also want to use a datetime picker - how would I code the view use the code above, when it's not linked to a model, but just plain HTML?</p>
  
  <p>If I just enter the following into my Razor markup:</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      &lt;p&gt;
          Availability between: @Html.TextBox( "From" , String.Format( "{0:dd/MM/yyyy}") , new  { @class = "datepicker span2" } ) 
                           and: @Html.TextBox( "To" , String.Format( "{0:dd/MM/yyyy}") , new  { @class = "datepicker span2" } )
          &lt;input type="submit" value="Search" /&gt;&lt;/p&gt;
  }
  </code></pre>
  
  <p>I just get the error:</p>
  
  <pre><code>{"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."}
  </code></pre>
  
  <p>Thanks for any help,</p>
  
  <p>Mark</p>