ComponentOne Calendar for ASP.NET: Calendar for ASP.NET AJAX Task-Based Help > Selecting Dates > Assign the Value of the Selected Date to a TextBox

Assign the Value of the Selected Date to a TextBox

To use the SelectedDate property to get the value of the selected date when you select a date on the calendar control at run time, complete the following:

1.   Add a C1Calendar control to the page.

2.   Add an ASP.NET TextBox control to the page.

3.   In C1Calendar's Properties window, change the AutoPostBackOnSelect property to True to post back to the server when you select a date on the calendar.

4.   Add the following code in the page load event to assign the value of the selected date on the calendar control to the text box:

      Visual Basic

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Me.TextBox1.Text = C1Calendar1.SelectedDate.ToString()

End Sub

      C#

protected void Page_Load(object sender, EventArgs e)

    {

        this.TextBox1.Text = C1Calendar1.SelectedDate.ToString();

    }

This Topic Illustrates the Following:

When you select a date from the calendar control at run time, the value of the selected date is displayed on the TextBox control.

 


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.