ComponentOne Scheduler for ASP.NET: Scheduler for ASP.NET AJAX Task-Based Help > Client-Side Tasks > Getting and Setting the Display Date in Day View

Getting and Setting the Display Date in Day View

This topic explains how to set the date that appear in a DayView schedule, as well as how to set an alert showing the date currently appearing in the schedule.

To set the first date to appear in the schedule:

1.   Add two Input (Button) controls to your form. This control can be found on the HTML tab of the toolbox. If necessary, right-click the Toolbox and select Show All to view all tabs.

2.   Select the first Input (Button) and set its Value property to Set Date in the Visual Studio Properties window.

3.   Set the Value property of the second Input (Button) to Get Date. Your form will now look like the following image.

 

 

4.   Double-click the Set Date button. A new JavaScript function base is automatically generated and added to the Web form, which is shown in Source view.

5.   Add the following script to the base, as in the following example:

function Button1_onclick() {

aJSDate=new Date(2009,3,10);

var schedule = $get("C1Schedule1").control;

schedule.setDisplayDate(aJSDate);

}

This code uses the setDisplayDate client-side method to set the first date in the calendar to February 10, 2007 when the Set Date button is clicked.

6.   Run the project. Notice the current date is the date that appears in the calendar.

7.   Click the Set Date button. The date changes to March 10, 2009.

8.   Go back to the project designer, and now add code for the Get Date button.

To set an alert showing the first date:

1.   Double-click the Get Date button. A new JavaScript function base is automatically generated and added to the Web form, which is shown in Source view.

2.   Add the following code to the base, as in the following example:

function Button2_onclick() {

var schedule = $get("C1Schedule1").control;

alert(schedule.getDisplayDate());

}

This code uses the getDisplayDate client-side method to show an alert box with the date that is currently shown in the schedule.

3.   Run the project. Notice the current date is the date that appears in the schedule.

4.   Click the Get Date button. The date in the schedule appears in the alert box.


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