title: Set Textbox = Today() When Null
body: <p>I have a webform where I have two textboxes and the user is supposed to input a date.  Sometimes the user will not input a date, and I do not want to make the input required, so to combat this, i want to set the NULL textbox value to today's date.  This is the syntax that I am working with, but my compiler is giving me an error of (2 different errors)</p>
  
  <blockquote>
    <p>Use of unassigned local variable 'ads'<br>
    Use of unassigned local variable 'ade'</p>
  </blockquote>
  
  <p>What do I need to do alter so that my code will 
  <br>1) If the textbox is not null, accept the date input<br>
  2) if the textbox is null, force the textbox to show todays date?</p>
  
  <pre><code>DateTime ads;
  DateTime ade;
  DateTime today = DateTime.Today;
  string s_today = today.ToString("MM/dd/yyyy");
  
  string a = txtads.Text;
  if (a != "")
  {
    ads = Convert.ToDateTime(a);
    txtads.Text = ads.ToShortDateString();
  }
  else { txtads.Text = s_today;}
  string b = txtade.Text;
  if (b != "")
  {
    ade = Convert.ToDateTime(b);
    txtade.Text = ade.ToShortDateString();
  }
  else { txtade.Text = s_today; }
  Runthisstoredparemterizedprocedure(database, ads, ade);
  </code></pre>