ToBe

ToBe

  • NA
  • 164
  • 94.4k

textbox is not reading the new selection of calendar

May 9 2013 4:31 AM
hi 

I have problem with the textbox reading from a calendar 

I to make the default value for the textbox is the system date which is working now in my code and when the user click the button to change it it should save the selected date in the textbox value and hide the calendar but it's not taking it .

this is my code :

  protected void Page_Load(object sender, EventArgs e)
        {


            if (!IsPostBack)
            {
                DateTime today = DateTime.Today;


                Calendar1.TodaysDate = today;
                Calendar1.SelectedDate = Calendar1.TodaysDate;
                TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
                Calendar1.Visible = false;
            }
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Calendar1.Visible == true)


            {
                TextBox1.Text = Calendar1.SelectedDate.Date.ToString();
                Calendar1.Visible = false;


            }
            else
            {
                Calendar1.Visible = true;


               
            }


           
        }


       
    }
}



Answers (2)