title: Ajax CalendarExtender, How to get the date after i click on a button?
body: <p>I want to add add an Ajax CalendarExtender  to my page. And then after selecting a date and clicking on a button I get the selected Day in a label.</p>
  
  <p>I have a text box which is the target of the CalendarExtender</p>
  
  <pre><code>&lt;asp:TextBox ID="DateText" runat="server" ReadOnly="true" &gt;&lt;/asp:TextBox&gt;
  
  &lt;ajaxToolkit:CalendarExtender 
      ID="Calendar1"
      runat="server"
      TargetControlID="DateText"
      Format="MMMM d, yyyy"
      PopupPosition="Right"
      /&gt;
  
  &lt;asp:Button runat="server" ID="Button1" onclick="Button1_Click" /&gt;
  </code></pre>
  
  <p>In the <strong>Code Behind</strong>:</p>
  
  <p>On the first page load I set the date to Today.</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          Calendar1.SelectedDate = DateTime.Today;
      }
  }
  </code></pre>
  
  <p>In the Button1_Click Event</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      Label1.Text = Calendar1.SelectedDate.Value.Day.ToString();
  }
  </code></pre>
  
  <p>The problem is when I click the button (or after any post backs) the value selected get reset to Today's date.</p>
  
  <p>And if I don't set it to <code>DateTime.Today</code> in the <code>Page_Load</code> It get reset to null and throw a null exception.</p>
  
  <p>How can I solve this?</p>
  
  <p>Thank you very much for any help.
  I hope i was clear</p>