title: Parse TextBox to SqlDbType.Date as "dd.MM.yyyy"
body: <p>I want dates to look on page like dd.MM.yyyy.
  Me like this way, which is culture-independent.</p>
  
  <p>I don't know how make it right.</p>
  
  <pre><code>cmd.Parameters.Add("@eventdate", SqlDbType.Date).Value = dateAddTxtBox.Text;
  </code></pre>
  
  <p>Format Exception:</p>
  
  <blockquote>
    <p>String was not recognized as a valid DateTime</p>
  </blockquote>
  
  <p>I tried many snippets like <code>DateTime.ParseExact(dateAddTxtBox.Text, "dd.MM.yyyy", null)</code> or using <code>System.Globalization.CultureInfo.InvariantCulture</code> as well. Nothing helped!</p>
  
  <p>Or maybe it will better done in SQL procedure side, won't it?</p>
  
  <pre><code>CREATE PROCEDURE add_history
  @user       VARCHAR(20),
  @eventdate  DATE,
  ...
  INSERT INTO History(userid, eventdate, ...)
  VALUES ((SELECT userid FROM Users.SUsers WHERE suname=@user), @eventdate, ...)
  </code></pre>
  
  <p>All worked pretty good while I haven't format my TextBoxes with pattern:</p>
  
  <pre><code>&lt;asp:TextBox id="dateAddTxtBox" runat="server" ReadOnly="True" /&gt;
  &lt;asp:CalendarExtender ID="AddTxtBoxCalendarExtender" runat="server" Enabled="True" TargetControlID="dateAddTxtBox" Format="dd.MM.yyyy" ... /&gt;
  </code></pre>
  
  <p>UPD:</p>
  
  <p>A little mention >> there was read-only attribute on TextBox.
  That's why it didn't work!</p>
  
  <p>Now the question is, is it correct to skip <code>ReadOnly="True"</code>? I don't want users to edit dates right in the box.</p>
  
  <p>UPD2:</p>
  
  <p><code>ReadOnly="True"</code> doesn't make a sense at all. It works fine as it should! I don't know why.</p>