我已经在 asp.net C# 环境中实现了代码,以便从 Telerik 树视图拖放到 Telerik 调度程序中以创建约会。
有时,通过从 Telerik 树视图拖放到 Telerik 调度程序来安排任何约会时,我只会在 Chrome 中遇到问题。
错误描述如下:
“1176.666697837689 不是 Int32 的有效值。” 每次十进制值都在变化。
错误 ExceptionStackTrace 如下:
at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.AssignToPropertyOrField(Object propertyValue, Object o, String memberName, JavaScriptSerializer serializer, Boolean throwOnError)
at System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
at Telerik.Web.UI.RadScheduler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
我使用下面的代码从 Telerik 树视图拖放到 Telerik Scheduler :
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
//<![CDATA[
//Shows whether an Appointment is inserted directry, or the
//the Advanced Insert Form is opened when TreeView node is dropped on the Scheduler.
var directlyInsertAppointment = true;
var selectedAppointment = null;
function nodeDropping(sender, eventArgs) {
var htmlElement = eventArgs.get_htmlElement();
var scheduler = $find('<%= RadScheduler1.ClientID %>');
if (isPartOfSchedulerAppointmentArea(htmlElement)) {
//Gets the TimeSlot where an Appointment is dropped.
var timeSlot = scheduler.get_activeModel().getTimeSlotFromDomElement(htmlElement);
var startTime = timeSlot.get_startTime();
var startTimes = startTime.toDateString() + " " + startTime.toTimeString();
document.getElementById('<%= hdnScheduledStartDateTime.ClientID %>').value = startTimes;
//Gets all the data needed for the an Appointment, from the TreeView node.
var node = eventArgs.get_sourceNode();
var text = node.get_text();
document.getElementById('<%= hdnSessionSubject.ClientID%>').value = text;
var nodeVal = node.get_value();
document.getElementById('<%= hdnPTSessionsClientManagementId.ClientID %>').value = nodeVal;
var attributes = node.get_attributes();
var PTSessionMgmtID = attributes.getAttribute("PTSessionsManagementId");
document.getElementById('<%= hdnPTSessionsManagementId.ClientID %>').value = PTSessionMgmtID;
var SessionTypeId = attributes.getAttribute("SessionTypeId");
document.getElementById('<%= hdnSessionTypeId.ClientID %>').value = SessionTypeId;
var duration = attributes.getAttribute("Duration");
var endTime = new Date(startTime);
endTime.setMinutes(parseInt(endTime.getMinutes()) + parseInt(duration));
var endTimes = endTime.toDateString() + " " + endTime.toTimeString();
document.getElementById('<%= hdnScheduledEndDateTime.ClientID %>').value = endTimes;
var parentValue = node.get_parent().get_value();
var category = scheduler.get_resources().getResourceByTypeAndKey("Category", parentValue);
//New appointment is created. The start/end time, subject and category are set.
var newAppointment = new Telerik.Web.UI.SchedulerAppointment();
newAppointment.set_start(startTime);
newAppointment.set_end(endTime);
newAppointment.set_subject(text);
if (category != null) {
newAppointment.get_resources().add(category);
}
//Checks for the user's choice of the method for inserting Appointments.
if (directlyInsertAppointment) {
scheduler.insertAppointment(newAppointment);
} else {
//If Advanced Form is opened, the information from the TreeVew node is stored in a hidden input.
var appointmentInfo = { subject: text, duration: duration, category: category };
var appointmentInfoSerialized = Sys.Serialization.JavaScriptSerializer.serialize(appointmentInfo);
$get("<%=HiddenInputAppointmentInfo.ClientID%>").value = appointmentInfoSerialized;
scheduler.showInsertFormAt(timeSlot);
}
}
else {
//The node was dropped elsewhere on the document.
eventArgs.set_cancel(true);
}
}
</script>
此功能在本地服务器上正常工作,但不知何故它在客户端服务器上不起作用,有时在 Chrome 浏览器中。