PDA

View Full Version : [CLOSED] htmlEditor error when saving or adding data on OnBeforeStoreChanged, (500) internal communication error



DenisEdde
Sep 15, 2014, 7:00 PM
When saving and adding data using the OnBeforeStoreChanged event, it succeeds and the event fires when the htmlEditor contains one line of text, But when I go to a new line in the htmlEditor and click Save or Create, the OnBeforeStoreChanged event doesn't fire and a (500) internal communication error is returned from inside the funcions grid.store.insert() or form.getForm().updateRecord() aspx page code:
Mail Template


Code Behind C#
/// /// Insert MailTemplate /// ///
/// private int AddMailTemplate(MailTemplate aps) { try { lock (lockObj) { aps = MailTemplateBLL.Insert(aps); return aps.MailTemplateId; } } catch (Exception ex) { new CustomException(ex, ErrorType.Base); throw ex; } } /// /// Delete MailTemplate /// ///
private void DeleteMailTemplate(int MailTemplateId) { try { lock (lockObj) { MailTemplate aps = null; aps = MailTemplateBLL.Get(MailTemplateId); if (aps == null) { throw new Exception("MailTemplate not found, in ManageMailTemplate.aspx in DeleteMailTemplate"); } if (aps.MailTemplateId == MailTemplateId) MailTemplateBLL.Delete(MailTemplateId); } } catch (Exception ex) { new CustomException(ex, ErrorType.Base); throw ex; } } /// /// Update MailTemplate /// ///
private void UpdateMailTemplate(MailTemplate aps) { try { lock (lockObj) { MailTemplate updatingAps = null; updatingAps = MailTemplateBLL.Get(aps.MailTemplateId); if (updatingAps == null) { throw new Exception("MailTemplate not found, in ManageMailTemplate.aspx in UpdateMailTemplate"); } if (updatingAps.MailTemplateId == aps.MailTemplateId) { updatingAps.Name = aps.Name; updatingAps.FromAddress = aps.FromAddress; updatingAps.Subject = aps.Subject; updatingAps.Body = aps.Body; updatingAps.Enabled = aps.Enabled; } else throw new Exception("MailTemplate not found, in ManageMailTemplate.aspx in UpdateMailTemplate"); MailTemplateBLL.Update(updatingAps); } } catch (Exception ex) { new CustomException(ex, ErrorType.Base); throw ex; } } /// /// Update Store when Adding, Deleting and Updating a record /// ///
///
protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e) { try { List listAps = e.DataHandler.ObjectData(); if (e.Action == StoreAction.Create) { foreach (MailTemplate created in listAps) { this.AddMailTemplate(created); e.ResponseRecords.Add(created); } } if (e.Action == StoreAction.Destroy) { foreach (MailTemplate deleted in listAps) { this.DeleteMailTemplate(deleted.MailTemplateId); //e.ResponseRecords.Add(new {}); } } if (e.Action == StoreAction.Update) { foreach (MailTemplate updated in listAps) { this.UpdateMailTemplate(updated); e.ResponseRecords.Add(updated); } } e.Cancel = true; } catch (Exception ex) { new CustomException(ex, ErrorType.Base); throw ex; } }

Daniil
Sep 16, 2014, 5:26 AM
Hi @DenisEdde,

Unfortunately, the test case throws a Compilation Error when I try to run it.

CS0246: The type or namespace name 'MailTemplate' could not be found (are you missing a using directive or an assembly reference?)


Please provide a runnable and a standalone test case. Please see Example (Very Helpful) here:
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)