title: Ext.Net retrieve DateField with GetCmp
body: <p>I have a web page in ASP + Ext.Net in c# where I create some controls dynamically (text fields, comboboxes, datefields etc) based on an XML. When the user presses a button I have to read the values of those controls and do something with it, so I am using Ext.Net.X.GetCmp to do that. It works just fine for all controls, unless the control is a date control (T=DateField), and unless it has a custom date format (e.g. "dd MMM yyyy"). In that case, it returns a FormatException when I Try to retrieve the control.</p>
  
  <p>A very short example to reproduce the problem:</p>
  
  <p><strong>ASPX:</strong></p>
  
  <pre><code>&lt;%@ Page Language="C#" CodeBehind="Sandbox.aspx.cs" Inherits="MyNamespace.Sandbox" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Multiple DateFields with DateRange Validation - Ext.NET Examples&lt;/title&gt;
      &lt;link href="/resources/css/examples.css" rel="stylesheet" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form runat="server"&gt;
          &lt;ext:ResourceManager runat="server" /&gt;
  
  
          &lt;ext:Window 
              runat="server" 
              Width="350"
              Title="DateRange"
              Icon="Date"
              Closable="false"
              BodyPadding="5"
              Layout="Anchor"
              DefaultAnchor="100%"&gt;
              &lt;Items&gt;
                  &lt;ext:Button ID="MyTestButton" runat="server" Flex="1" Text="Test" ToolTip="Click here to crash" OnDirectClick="ButtonClicked" /&gt;
                  &lt;ext:FieldContainer
                      ID="MyFieldContainer"
                      runat="server"
                      &gt;
                      &lt;Items&gt;
                          &lt;%--HERE I CREATE A DATEFIELD IN CODE BEHIND--%&gt;
                      &lt;/Items&gt;
                  &lt;/ext:FieldContainer&gt;
              &lt;/Items&gt;           
          &lt;/ext:Window&gt;                
     &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Code behind (C#):</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using Ext.Net;
  
  namespace MyNamespace {
      public partial class Sandbox : System.Web.UI.Page {
          protected void Page_Load(object sender, EventArgs e) {
              if (!this.Page.IsPostBack) {
                  CreateDateField();
              }
          }
  
          protected void CreateDateField() {
              DateField date = new DateField() {
                  ID = "MyDateField",
                  //FieldLabel = "From",
                  Format = "dd MMM yyyy",
                  SubmitFormat = "dd/MM/yyyy",
                  Value = "01 Jun 2014"
              };
              date.AddTo(MyFieldContainer);
          }
  
          [DirectMethod]
          public void ButtonClicked(object sender, DirectEventArgs e) {
              // Try to retrieve the control.
              // Spoiler alert: it will crash
              DateField date = Ext.Net.X.GetCmp&lt;DateField&gt;("MyDateField");
              // Change the date to see if it worked.
              date.Value = "02 Jun 2014";
          }
      }
  }
  </code></pre>
  
  <p>The error I get is just a System.FormatException: String was not recognized as a valid DateTime. I have tried playing with the SubmitFormat property with no luck. Again, with the default date format it works just fine, but a requirement for the customer is to have their custom date format.</p>
  
  <p>What am I doing wrong? Thank you very much for the help.</p>