0

I am trying to set a calendar server control (in visual studio) to a custom month and year that is selected by a user using a drop down list for months and one for years. I have it so that the calendar does not appear until both month and year are selected from the drop down. I am not sure where to go now so that when the calendar appears, it is set to the month and year selected, allowing the user to select the day they were born from the calendar once it appears. I am using C# for my code behind. Here is my code behind code for my page:

  protected void DropDownListYear_SelectedIndexChanged(object sender, EventArgs e)
  {
    if (DropDownListMonth.SelectedIndex != 0)
    {
      CalendarBday.Visible = true;

      CalendarBday.SelectMonthText = DropDownListMonth.Text;
     }
   }
   protected void DropDownListMonth_SelectedIndexChanged(object sender, EventArgs e)
   {
     if (DropDownListYear.SelectedIndex != 0)
     {
       CalendarBday.Visible = true;
     }
    }
Alberto
  • 15,626
  • 9
  • 43
  • 56
Stc5097
  • 291
  • 1
  • 11
  • 25
  • so i added this to my code: int year = DropDownListYear.Text; CalendarBday.VisibleDate = new DateTime(year, 2, 1); But how do i get it to accept variables instead of numbers for parameters. I get an error when i try to put year in it instead of a number – Stc5097 Feb 14 '14 at 04:01
  • I suggest edit your question with the new above code, and also include the actual error you're getting, and what line it occurs on. That is better than adding a comment, especially with code which is hard to read in comments. – Dmitriy Khaykin Feb 14 '14 at 04:45

0 Answers0