How to add an event to the Form designer calendar control

You can add a custom event handler to a date field that will be triggered after a date has been selected in the Form designer calendar control. To do this:

  1. Open the form in .NET code edit mode.

  2. In the Page_Load event, set the AutoPostBack property to TRUE on the calendar pop-up.

    Example for a date input with the ID DATE inside a section with the ID REQUEST:

    REQUEST_DATE_CAL.AutoPostBack = true;

  3. Add the DateChanged event handler.

Sample code:

protected void Page_Load(object sender, EventArgs e)

{

 base.Page_Load(sender, e);

 

 if(!IsPostBack)

 {

 // Set the obligatory AutoPostBack property on the CalendarPopup

 REQUEST_DATE_CAL.AutoPostBack = true;

 }

 

 // Add the DateChanged event handler

 REQUEST_DATE_CAL.DateChanged += REQUEST_DATE_CAL_DateChanged;

}

 

protected void REQUEST_DATE_CAL_DateChanged(object sender, EventArgs e)

{

 // Get the selected date (DateTime) like so: **REQUEST_DATE_CAL.SelectedDate**

}

Is it for this control?

I’m asking, because it is TextBox control with additional image button what opens calendar control.
It handles only TextChanged event.
But I have a problem with this. Even I set autopostback=true (both: form design or code behind side) it doesn’t cause any action after date change.
Any advice?

Are you setting an Autopostback attribute to REQUEST_DATE_CAL (CalendarPopup field) or REQUEST_DATE(TextBox field)?

You can’t add an Autopostback attribute to the REQUEST_DATE_CAL field in the form designer, it is only possible in code behind like mentioned in this article.

Best Regards,
Eddy.

Right, thank you.
I should read docs more carefully :slight_smile: