This example demonstrates how to use client appointment objects and methods to implement an appointment edit form with custom fields that operate through client scripts.
Files to Review
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- ScriptAppointmentForm.ascx (VB: ScriptAppointmentForm.ascx)
- ScriptRecurrenceForm.ascx (VB: ScriptRecurrenceForm.ascx)
Example Code
ASPx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dxpc" %>
<%@ Register Assembly="DevExpress.Web.ASPxScheduler.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxScheduler" TagPrefix="dxwschs" %>
<%@ Register Assembly="DevExpress.XtraScheduler.v15.2.Core, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraScheduler" TagPrefix="dxschsc" %>
<%@ Register Src="~/UserForms/ScriptAppointmentForm.ascx" TagName="ScriptAppointmentForm" TagPrefix="form" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web" TagPrefix="dxe" %>
<%@ Register Src="~/DefaultObjectDataSource.ascx" TagPrefix="demo" TagName="ObjectDataSource" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<script type="text/javascript"><!--
function OnMenuItemClick(s, e) {
e.handled = true;
switch(e.itemName) {
case ASPx.SchedulerMenuItemId.NewAppointment:
NewAppointment(scheduler);
break;
case ASPx.SchedulerMenuItemId.NewRecurringAppointment:
NewRecurringAppointment(scheduler);
break;
case ASPx.SchedulerMenuItemId.NewAllDayEvent:
NewAllDayEvent(scheduler);
break;
case ASPx.SchedulerMenuItemId.NewRecurringEvent:
NewRecurringEvent(scheduler);
break;
case ASPx.SchedulerMenuItemId.OpenAppointment:
OpenAppointment(scheduler);
break;
case ASPx.SchedulerMenuItemId.EditSeries:
EditSeries(scheduler);
break;
default:
e.handled = false;
}
}
function OpenAppointment(scheduler) {
var apt = GetSelectedAppointment(scheduler);
scheduler.RefreshClientAppointmentProperties(apt, AppointmentPropertyNames.Normal + ";Price", OnAppointmentRefresh);
}
function EditSeries(scheduler) {
var apt = GetSelectedAppointment(scheduler);
scheduler.RefreshClientAppointmentProperties(apt, AppointmentPropertyNames.Pattern + ";Price", OnAppointmentEditSeriesRefresh);
}
function OnAppointmentRefresh(apt) {
ShowAppointmentForm(apt);
}
function OnAppointmentEditSeriesRefresh(apt) {
if (apt.GetRecurrencePattern()) {
var pattern = apt.GetRecurrencePattern();
ShowAppointmentForm(pattern);
}
}
function NewAppointment(scheduler) {
var apt = CreateAppointment(scheduler)
ShowAppointmentForm(apt);
}
function NewRecurringAppointment(scheduler) {
var apt = CreateRecurringAppointment(scheduler);
ShowAppointmentForm(apt);
}
function NewRecurringEvent(scheduler) {
var apt = CreateRecurringEvent(scheduler);
ShowAppointmentForm(apt);
}
function NewAllDayEvent(scheduler) {
var apt = CreateAllDayEvent(scheduler);
ShowAppointmentForm(apt);
}
function ShowAppointmentForm(apt) {
MyScriptForm.Clear();
MyScriptForm.Update(apt);
if (apt.GetSubject() != "")
myFormPopup.SetHeaderText(apt.GetSubject() +" - Appointment");
else
myFormPopup.SetHeaderText("Untitled - Appointment");
myFormPopup.Show();
}
function CloseAppointmentForm() {
myFormPopup.Hide();
myFormPopup.SetSize(0,0);
}
function CreateAppointment(scheduler) {
var apt = new ASPxClientAppointment();
var selectedInterval = scheduler.GetSelectedInterval();
apt.SetStart(selectedInterval.GetStart());
apt.SetEnd(selectedInterval.GetEnd());
apt.AddResource(scheduler.GetSelectedResource());
apt.SetLabelId(0);
apt.SetStatusId(0);
return apt;
}
function CreateRecurringAppointment(scheduler) {
var apt = CreateAppointment(scheduler);
apt.SetAppointmentType(ASPxAppointmentType.Pattern);
var recurrenceInfo = new ASPxClientRecurrenceInfo();
recurrenceInfo.SetStart(apt.GetStart());
recurrenceInfo.SetEnd(apt.GetEnd());
apt.SetRecurrenceInfo(recurrenceInfo);
return apt;
}
function CreateAllDayEvent(scheduler) {
var apt = CreateAppointment(scheduler);
var start = apt.interval.start;
var today = new Date(start.getFullYear(), start.getMonth(), start.getDate());
apt.SetStart(today);
apt.SetDuration(24 * 60 * 60 * 1000);
apt.SetAllDay(true);
return apt;
}
function CreateRecurringEvent(scheduler) {
var apt = CreateAllDayEvent(scheduler);
apt.SetAppointmentType(ASPxAppointmentType.Pattern);
var recurrenceInfo = new ASPxClientRecurrenceInfo();
recurrenceInfo.SetStart(apt.GetStart());
recurrenceInfo.SetEnd(apt.GetEnd());
apt.SetRecurrenceInfo(recurrenceInfo);
return apt;
}
function GetSelectedAppointment(scheduler) {
var aptIds = scheduler.GetSelectedAppointmentIds();
if (aptIds.length == 0)
return;
var apt = scheduler.GetAppointmentById(aptIds[0]);
return apt;
}
//--></script>
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<demo:ObjectDataSource runat="server" ID="objectDataSource" SessionName="test" />
<asp:SqlDataSource ID="CarsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:XtraCarsConnectionString %>"
SelectCommand="SELECT [ID], [Model] FROM [Cars]"></asp:SqlDataSource>
<br />
<dxwschs:ASPxScheduler ID="ASPxScheduler1" runat="server" ClientInstanceName="scheduler"
ActiveViewType="Timeline" GroupType="Resource" OnBeforeExecuteCallbackCommand="ASPxScheduler1_BeforeExecuteCallbackCommand">
<ClientSideEvents MenuItemClicked="function(s, e) { OnMenuItemClick(s,e); }"/>
<Views>
<DayView ResourcesPerPage="3">
<DayViewStyles ScrollAreaHeight="400px">
</DayViewStyles>
</DayView>
<MonthView NavigationButtonVisibility="Always" ResourcesPerPage="3">
</MonthView>
<TimelineView ResourcesPerPage="3">
<AppointmentDisplayOptions AppointmentAutoHeight="True" />
</TimelineView>
</Views>
</dxwschs:ASPxScheduler>
<dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="myFormPopup" AllowDragging="true" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Width="0px" Height="0px" Modal="true" CloseAction="CloseButton">
<ContentCollection>
<dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
<form:ScriptAppointmentForm runat="server" ID="AppointmentForm" SchedulerId="ASPxScheduler1" ClientInstanceName="MyScriptForm" ClientSideEvents-FormClosed="function(s, e) { CloseAppointmentForm();}" />
</dxpc:PopupControlContentControl>
</ContentCollection>
</dxpc:ASPxPopupControl>
</div>
</form>
</body>
</html>
C#using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.XtraScheduler;
using DevExpress.Web.ASPxScheduler;
using DevExpress.Web.ASPxScheduler.Internal;
using System.Drawing;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
// Data binding should be performed manually
DataHelper.SetupDefaultMappings(ASPxScheduler1);
DataHelper.ProvideRowInsertion(ASPxScheduler1, objectDataSource.AppointmentDataSource);
objectDataSource.AttachTo(ASPxScheduler1);
if(!IsPostBack) {
AppointmentForm.DataBind();
}
}
protected void ASPxScheduler1_BeforeExecuteCallbackCommand(object sender, SchedulerCallbackCommandEventArgs e) {
if(e.CommandId == SchedulerCallbackCommandId.ClientSideUpdateAppointment)
e.Command = new MyUpdateAppointmentCommand((ASPxScheduler)sender);
else if (e.CommandId == SchedulerCallbackCommandId.ClientSideInsertAppointment)
e.Command = new MyInsertAppointmentCommand((ASPxScheduler)sender);
}
}
class MyInsertAppointmentCommand : AppointmentClientSideInsertCallbackCommand {
public MyInsertAppointmentCommand(ASPxScheduler scheduler) : base(scheduler) {
}
protected override AppointmentFormController CreateAppointmentFormController(Appointment apt) {
return new MyAppointmentFormController(Control, apt);
}
protected override void AssignControllerCustomFieldsValues(AppointmentFormController controller, ClientAppointmentProperties clientAppointment) {
Appointment editedAppointment = controller.EditedAppointmentCopy;
double result = 0;
if(clientAppointment.Properties["Price"] != null)
Double.TryParse(clientAppointment.Properties["Price"].ToString(), out result);
editedAppointment.CustomFields["Price"] = result;
base.AssignControllerCustomFieldsValues(controller, clientAppointment);
}
}
class MyUpdateAppointmentCommand : AppointmentClientSideUpdateCallbackCommand {
public MyUpdateAppointmentCommand(ASPxScheduler scheduler)
: base(scheduler) {
}
protected override AppointmentFormController CreateAppointmentFormController(Appointment apt) {
return new MyAppointmentFormController(Control, apt);
}
protected override void AssignControllerCustomFieldsValues(AppointmentFormController controller, ClientAppointmentProperties clientAppointment) {
Appointment editedAppointment = controller.EditedAppointmentCopy;
double result = 0;
if(clientAppointment.Properties["Price"] != null)
Double.TryParse(clientAppointment.Properties["Price"].ToString(), out result);
editedAppointment.CustomFields["Price"] = result;
base.AssignControllerCustomFieldsValues(controller, clientAppointment);
}
}
public class MyAppointmentFormController : AppointmentFormController {
private const string PriceFieldName = "Price";
public MyAppointmentFormController(ASPxScheduler control, Appointment apt)
: base(control, apt) {
}
public double Price { get { return (double)EditedAppointmentCopy.CustomFields[PriceFieldName]; } set { EditedAppointmentCopy.CustomFields[PriceFieldName] = value; } }
double SourcePrice { get { return (double)SourceAppointment.CustomFields[PriceFieldName]; } set { SourceAppointment.CustomFields[PriceFieldName] = value; } }
protected override void ApplyCustomFieldsValues() {
SourcePrice = Price;
}
}
Code<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ScriptAppointmentForm.ascx.cs" Inherits="UserForms_ScriptAppointmentForm" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxScheduler.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxScheduler.Controls" TagPrefix="dxsc" %>
<%@ Register Assembly="DevExpress.Web.ASPxScheduler.v15.2, Version=15.2.20.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxScheduler" TagPrefix="dxwschs" %>
<%@ Register Src="~/UserForms/ScriptRecurrenceForm.ascx" TagName="RecurrenceControl" TagPrefix="recur" %>
<table class="dxscAppointmentForm" cellpadding="0" cellspacing="0" style="width: 500px;
height: 100px;">
<tr>
<td class="dxscDoubleCell" colspan="2">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell">
<dxe:ASPxLabel ID="lblSubject" runat="server" AssociatedControlID="tbSubject" Text="Subject:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxTextBox ID="tbSubject" runat="server" Width="100%" EnableClientSideAPI="true"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell">
<dxe:ASPxLabel ID="lblLocation" runat="server" AssociatedControlID="tbLocation" Text="Location:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxTextBox ID="tbLocation" runat="server" Width="100%" EnableClientSideAPI="true"/>
</td>
</tr>
</table>
</td>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell" style="padding-left: 25px;">
<dxe:ASPxLabel ID="lblLabel" runat="server" AssociatedControlID="edtLabel" Text="Label:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxComboBox ID="edtLabel" runat="server" Width="100%" DataSource='<%# LabelDataSource %>' />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell">
<dxe:ASPxLabel ID="lblStartDate" runat="server" AssociatedControlID="edtStartDate"
Text="Start time:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxDateEdit ID="edtStartDate" runat="server"
Width="100%" EditFormat="DateTime" />
</td>
</tr>
</table>
</td>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell" style="padding-left: 25px;">
<dxe:ASPxLabel runat="server" ID="lblEndDate" Text="End time:" AssociatedControlID="edtEndDate" />
</td>
<td class="dxscControlCell">
<dxe:ASPxDateEdit ID="edtEndDate" runat="server" EditFormat="DateTime" Width="100%">
</dxe:ASPxDateEdit>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell">
<dxe:ASPxLabel ID="lblStatus" runat="server" AssociatedControlID="edtStatus" Text="Show time as:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxComboBox ID="edtStatus" runat="server" Width="100%" DataSource='<%# StatusDataSource %>' />
</td>
</tr>
</table>
</td>
<td class="dxscSingleCell" style="padding-left: 22px;">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 20px; height: 20px;">
<dxe:ASPxCheckBox ID="chkAllDay" runat="server" />
</td>
<td style="padding-left: 2px;">
<dxe:ASPxLabel ID="lblAllDay" runat="server" Text="All day event" AssociatedControlID="chkAllDay" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell">
<dxe:ASPxLabel ID="lblResource" runat="server" AssociatedControlID="edtResource" Text="Resource:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxComboBox ID="edtResource" runat="server" Width="100%" DataSource='<%# ResourceDataSource %>'/>
</td>
</tr>
</table>
</td>
<td class="dxscSingleCell">
<table class="dxscLabelControlPair" cellpadding="0" cellspacing="0">
<tr>
<td class="dxscLabelCell" style="padding-left: 25px;">
<dxe:ASPxLabel ID="lblPrice" runat="server" AssociatedControlID="edtPrice" Text="Price:">
</dxe:ASPxLabel>
</td>
<td class="dxscControlCell">
<dxe:ASPxTextBox ID="edtPrice" runat="server" Width="100%">
</dxe:ASPxTextBox>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="dxscDoubleCell" colspan="2" style="height: 90px;">
<dxe:ASPxMemo ID="tbDescription" runat="server" Width="100%" Rows="6" EnableClientSideAPI="true" />
</td>
</tr>
</table>
<dxe:ASPxCheckBox id="chkRecurrence" runat="server" Text="Recurrence">
</dxe:ASPxCheckBox>
<recur:RecurrenceControl runat="server" ID="recurrenceControl">
</recur:RecurrenceControl>
<table cellpadding="0" cellspacing="0" style="width: 500px; height: 35px;">
<tr>
<td style="width: 100%; height: 100%;" align="center">
<table style="height: 100%;">
<tr>
<td>
<dxe:ASPxButton runat="server" ID="btnOk" Text="OK" UseSubmitBehavior="false"
AutoPostBack="false" EnableViewState="false" Width="91px" />
</td>
<td>
<dxe:ASPxButton runat="server" ID="btnCancel" Text="Cancel"
UseSubmitBehavior="false" AutoPostBack="false" EnableViewState="false" Width="91px"
CausesValidation="False" />
</td>
<td>
<dxe:ASPxButton runat="server" ID="btnDelete" Text="Delete" EnableClientSideApi="true"
UseSubmitBehavior="false" AutoPostBack="false" EnableViewState="false" Width="91px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<script id="dxss_ASPxSchedulerClientAppoinmentForm" type="text/javascript"><!--
ASPxClientAppointmentForm = ASPx.CreateClass(ASPxClientFormBase, {
Initialize: function() {
this.controls.btnOk.Click.AddHandler(ASPx.CreateDelegate(this.OnBtnOkClick, this));
this.controls.btnCancel.Click.AddHandler(ASPx.CreateDelegate(this.OnBtnCancelClick, this));
this.controls.btnDelete.Click.AddHandler(ASPx.CreateDelegate(this.OnBtnDeleteClick, this));
this.controls.chkRecurrence.CheckedChanged.AddHandler(ASPx.CreateDelegate(this.OnChkRecurrenceChanged, this));
},
OnBtnOkClick: function(s, e) {
var apt = this.Parse();
this.Close();
if (apt.appointmentId)
this.scheduler.UpdateAppointment(apt);
else {
this.scheduler.InsertAppointment(apt);
}
},
OnBtnCancelClick: function(s, e) {
this.Close();
},
OnBtnDeleteClick: function(s, e) {
var apt = this.Parse();
this.Close();
this.scheduler.DeleteAppointment(apt);
},
OnChkRecurrenceChanged: function(s, e) {
var isChecked = s.GetChecked();
this.controls.recurrenceControl.SetVisible(isChecked);
},
Parse: function() {
var start = this.controls.edtStartDate.GetDate();
var end = this.controls.edtEndDate.GetDate();
var subject = this.controls.tbSubject.GetText();
var description = this.controls.tbDescription.GetText();
var location = this.controls.tbLocation.GetText();
var labelId = this.controls.edtLabel.GetValue();
var statusId = this.controls.edtStatus.GetValue();
var allDay = this.controls.chkAllDay.GetChecked();
var resourceId = this.controls.edtResource.GetValue();
var price = this.controls.edtPrice.GetValue();
var apt = new ASPxClientAppointment();
apt.SetAppointmentType(ASPxAppointmentType.Normal);
apt.SetStart(start);
apt.SetEnd(end);
apt.SetSubject(subject);
apt.SetDescription(description);
apt.SetLocation(location);
apt.SetLabelId(labelId);
apt.SetStatusId(statusId);
apt.SetAllDay(allDay);
apt.AddResource(resourceId);
apt.Price = price;
if (this.appointmentCopy && this.appointmentCopy.GetId())
apt.SetId(this.appointmentCopy.GetId());
if (this.controls.chkRecurrence.GetChecked()) {
apt.SetAppointmentType(ASPxAppointmentType.Pattern);
var recurrenceInfo = this.controls.recurrenceControl.Parse();
apt.SetRecurrenceInfo(recurrenceInfo);
}
return apt;
},
Update: function(apt) {
this.appointmentCopy = apt;
this.controls.edtPrice.SetText(apt.Price);
this.controls.edtStartDate.SetDate(apt.GetStart());
this.controls.edtEndDate.SetDate(apt.GetEnd());
this.controls.tbDescription.SetText(apt.GetDescription());
this.controls.tbSubject.SetText(apt.GetSubject());
this.controls.chkAllDay.SetChecked(apt.GetAllDay());
this.controls.edtLabel.SetValue(apt.GetLabelId());
this.controls.edtStatus.SetValue(apt.GetStatusId());
this.controls.tbLocation.SetText(apt.GetLocation());
var resourceIdValue = apt.GetResource(0);
resourceIdValue = (resourceIdValue == null) ? "null" : resourceIdValue;
this.controls.edtResource.SetValue(resourceIdValue);
var appointmentType = apt.GetAppointmentType();
if (appointmentType) {
if (appointmentType == ASPxAppointmentType.Normal || appointmentType == ASPxAppointmentType.Pattern) {
this.controls.chkRecurrence.SetVisible(true);
if (appointmentType == ASPxAppointmentType.Pattern) {
this.controls.recurrenceControl.SetVisible(true);
this.controls.chkRecurrence.SetVisible(true);
this.controls.chkRecurrence.SetChecked(true);
this.controls.recurrenceControl.Update(apt.GetRecurrenceInfo());
}
}
else {
this.controls.chkRecurrence.SetVisible(false);
}
}
this.controls.btnDelete.SetEnabled((apt.GetId()) ? true : false);
},
Clear: function() {
this.controls.edtStartDate.SetDate();
this.controls.edtEndDate.SetDate();
this.controls.tbDescription.SetText('');
this.controls.tbSubject.SetText('');
this.controls.chkAllDay.SetChecked(false);
this.controls.edtLabel.SetValue()
this.controls.edtStatus.SetValue()
this.controls.tbLocation.SetText('');
this.controls.chkRecurrence.SetChecked(false);
this.controls.edtResource.SetValue();
this.controls.recurrenceControl.Clear();
}
});
//--></script>
Code<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ScriptRecurrenceForm.ascx.cs" Inherits="UserForms_ScriptRecurrenceForm" %>
<%@ Register Assembly="DevExpress.Web.v15.2" Namespace="DevExpress.Web"
TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxScheduler.v15.2" Namespace="DevExpress.Web.ASPxScheduler.Controls"
TagPrefix="dxwschsc" %>
<div id="mainDiv">
<table>
<tr>
<td>
<dxwschsc:RecurrenceTypeEdit ID="edtRecurrenceTypeEdit" runat="server" ItemSpacing="10px" SelectedIndex="0" Border-BorderWidth="0px">
</dxwschsc:RecurrenceTypeEdit>
</td>
<td>
<dxwschsc:DailyRecurrenceControl ID="edtDailyRecurrenceControl" runat="server" ClientVisible="false">
</dxwschsc:DailyRecurrenceControl>
<dxwschsc:WeeklyRecurrenceControl ID="edtWeeklyRecurrenceControl" runat="server" ClientVisible="false">
</dxwschsc:WeeklyRecurrenceControl>
<dxwschsc:MonthlyRecurrenceControl ID="edtMonthlyRecurrenceControl" runat="server" ClientVisible="false">
</dxwschsc:MonthlyRecurrenceControl>
<dxwschsc:YearlyRecurrenceControl ID="edtYearlyRecurrenceControl" runat="server" ClientVisible="false">
</dxwschsc:YearlyRecurrenceControl>
</td>
</tr>
<tr>
<td colspan="2">
<dxwschsc:RecurrenceRangeControl ID="edtRecurrenceRangeControl" runat="server" >
</dxwschsc:RecurrenceRangeControl>
</td>
</tr>
</table>
</div>
<script id="dxss_ASPxSchedulerClientRecurrenceForm" type="text/javascript"><!--
ASPxClientRecurrenceAppointmentForm = ASPx.CreateClass(ASPxClientFormBase, {
Initialize: function() {
this.defaultRecurrenceInfo = new ASPxClientRecurrenceInfo();
this.controls.edtRecurrenceTypeEdit.SetSelectedIndex(0);
this.controls.edtDailyRecurrenceControl.SetClientVisible(true);
this.recurrenceEditors = new Object();
this.recurrenceEditors[ASPxClientRecurrenceType.Daily] = this.controls.edtDailyRecurrenceControl;
this.recurrenceEditors[ASPxClientRecurrenceType.Weekly] = this.controls.edtWeeklyRecurrenceControl;
this.recurrenceEditors[ASPxClientRecurrenceType.Monthly] = this.controls.edtMonthlyRecurrenceControl;
this.recurrenceEditors[ASPxClientRecurrenceType.Yearly] = this.controls.edtYearlyRecurrenceControl;
this.controls.edtRecurrenceTypeEdit.SelectedIndexChanged.AddHandler(ASPx.CreateDelegate(this.OnEdtRecurrenceTypeEditSelectedIndexChanged, this));
},
OnEdtRecurrenceTypeEditSelectedIndexChanged: function(s, e) {
for(var editor in this.recurrenceEditors)
this.recurrenceEditors[editor].SetClientVisible(false);
var activeEditor = this.recurrenceEditors[this.controls.edtRecurrenceTypeEdit.recurrenceType];
activeEditor.SetClientVisible(true);
},
Parse: function() {
var recurrenceInfo = new ASPxClientRecurrenceInfo();
var recurrenceType = this.controls.edtRecurrenceTypeEdit.GetRecurrenceType();
recurrenceInfo.SetRecurrenceType(recurrenceType);
var valueAccessor = this.recurrenceEditors[recurrenceInfo.type].valueAccessor;
recurrenceInfo.SetDayNumber(valueAccessor.GetDayNumber());
recurrenceInfo.SetPeriodicity(valueAccessor.GetPeriodicity());
recurrenceInfo.SetMonth(valueAccessor.GetMonth());
recurrenceInfo.SetWeekDays(valueAccessor.GetWeekDays());
recurrenceInfo.SetWeekOfMonth(valueAccessor.GetWeekOfMonth());
recurrenceInfo.SetRange(this.controls.edtRecurrenceRangeControl.GetRange());
recurrenceInfo.SetOccurrenceCount(this.controls.edtRecurrenceRangeControl.GetOccurrenceCount());
recurrenceInfo.SetStart(this.controls.edtRecurrenceRangeControl.GetEndDate());
recurrenceInfo.SetEnd(this.controls.edtRecurrenceRangeControl.GetEndDate());
return recurrenceInfo;
},
Update: function(recurrenceInfo) {
if (!recurrenceInfo)
return;
var recurrenceTypeToHide = this.controls.edtRecurrenceTypeEdit.GetRecurrenceType();
this.controls.edtRecurrenceTypeEdit.SetRecurrenceType(recurrenceInfo.type);
this.recurrenceEditors[recurrenceTypeToHide].SetVisible(false);
this.recurrenceEditors[recurrenceInfo.type].SetVisible(true);
this.controls.edtRecurrenceRangeControl.SetRange(recurrenceInfo.range);
this.controls.edtRecurrenceRangeControl.SetOccurrenceCount(recurrenceInfo.occurrenceCount);
this.controls.edtRecurrenceRangeControl.SetEndDate(recurrenceInfo.interval.GetEnd());
for(var editorType in this.recurrenceEditors) {
var editor = this.recurrenceEditors[editorType];
var actualRecurrenceInfo = (editorType == recurrenceInfo.type) ? recurrenceInfo : this.defaultRecurrenceInfo;
editor.Update(actualRecurrenceInfo);
}
},
Clear: function() {
this.Update(this.defaultRecurrenceInfo);
this.SetVisible(false);
},
SetVisible: function(isVisible) {
var element = ASPx.GetElementById('mainDiv');
this.SetVisibleCore(element, isVisible);
}
});
//--></script>