title: Using of Templated Helpers in MVC 2.0 : How can use the name of the property that I'm rendering inside template helper?
body: <p>I'm reviewing new features of ASP.NET MVC 2.0.
  During the review i found really interesting using Templated Helpers.</p>
  
  <p>As they described it, the primary reason of using them is to provide common way of how some datatypes should be rendered.</p>
  
  <p>Now i want to use this way in my project for DateTime datatype</p>
  
  <p>My project was written for the MVC 1.0 so generating of editbox is looking like this:</p>
  
  <pre><code>&lt;%= Html.TextBox("BirthDate", Model.BirthDate, new { maxlength = 10, size = 10, @class = "BirthDate-date" })%&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $(".BirthDate-date").datepicker({ showOn: 'button', buttonImage: '&lt;%=Url.Content("~/images/i_calendar.gif") %&gt;', buttonImageOnly: true });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Now i want to use Template Helper, so i want to have above code once i type next sentence:</p>
  
  <pre><code>&lt;%=Html.EditorFor(f=&gt;f.BirthDate) %&gt;
  </code></pre>
  
  <p>According to the manual I create DataTime.ascx partial view inside Shared/EditorTemplates folder.
  I put there above code and stacked with the problem.<br>
  <strong>How can i pass the name of the property that I'm rendering with template helper?</strong></p>
  
  <p>As you can see from my example, i really need it, since I'm using the name of the property to specify data value and parameter name that will be send during the POST requsest. Also, I'm using it to generate class name for JS calendar building.</p>
  
  <p>I tried to remove my partial class for template helper and made MVC to generate its default behavior. 
  Here what it generated for me:</p>
  
  <pre><code>&lt;input type="text" value="04/29/2010" name="LoanApplicationDays" id="LoanApplicationDays" class="text-box single-line"&gt;
  </code></pre>
  
  <p>As you can see, it used the name of the property for "name" and "id" attributes. 
  This example let me to presume that Template Helper knows about the name of the property.
  So, there should be some way of how to use it in custom implementation.</p>
  
  <p>Thanks for your help!</p>