public SecurePage.UpdateStatus DoUpdate(bool reportUnchanged) { SecurePage.UpdateStatus updateStatus; try { DataControl.AddCssClasses("badupdate"); // in case of exception if (!Validate()) { return(SecurePage.UpdateStatus.Failure); } var newValue = GetControlValue(); newValue = Feedback.StripHtml(newValue); newValue = newValue.StripRedundantSpaces(); var oldValue = GetCurrentValue(); if (oldValue == newValue) { DataControl.SetValue(newValue); updateStatus = SecurePage.UpdateStatus.Unchanged; } else { SecurePage.ThrowRandomException(); Log(oldValue, newValue); SetControlValue(newValue); if (Update(Convert(newValue))) { Feedback.AddInfo("The " + Description + " entry was updated."); updateStatus = SecurePage.UpdateStatus.Success; } else { updateStatus = SecurePage.UpdateStatus.Unchanged; } } AfterUpdate(newValue); if (updateStatus == SecurePage.UpdateStatus.Unchanged && reportUnchanged) { Feedback.AddInfo("The " + Description + " entry was unchanged."); } DataControl.RemoveCssClass("badupdate"); // ok now } catch (Exception ex) { Feedback.AddError("There was an unexpected error updating the " + Description); Feedback.HandleException(ex); updateStatus = SecurePage.UpdateStatus.Failure; } if (updateStatus == SecurePage.UpdateStatus.Success) { IncrementUpdateCount(); } return(updateStatus); }
protected virtual void InitializeItem(TemplateControl owner, bool addMonitorClasses = true, FeedbackContainerControl feedback = null) { _GroupName = _GroupName.SafeString(); var monitorClasses = addMonitorClasses ? $"mc mc-group-{_GroupName}-{Column}" .ToLowerInvariant() : null; DataControl = FindControl(owner, "Control" + _GroupName + Column); // owner.Master.FindMainContentControl("Control" + _GroupName + Column); if (addMonitorClasses) { DataControl.AddCssClasses(monitorClasses + " mc-data"); } var tooltip = DataControlToolTip; if (!IsNullOrWhiteSpace(tooltip)) { DataControl.SetToolTip(tooltip); DataControl.AddCssClasses("tiptip"); } Feedback = feedback ?? FindControl(owner, "Feedback" + _GroupName) as // owner.Master.FindMainContentControl("Feedback" + _GroupName) as FeedbackContainerControl; _Asterisk = FindControl(owner, "Asterisk" + _GroupName + Column) as //owner.Master.FindMainContentControl("Asterisk" + _GroupName + Column) as HtmlControl; Label = FindControl(owner, "Label" + _GroupName + Column) as //owner.Master.FindMainContentControl("Label" + _GroupName + Column) as HtmlControl; if (_Asterisk != null) { if (addMonitorClasses) { _Asterisk.AddCssClasses(monitorClasses + " mc-ast"); } tooltip = AsteriskToolTip; if (!IsNullOrWhiteSpace(tooltip)) { _Asterisk.Attributes.Add("title", tooltip); _Asterisk.AddCssClasses("tiptip"); } } var expandable = FindControl(owner, "Expandable" + _GroupName + Column); //owner.Master.FindMainContentControl("Expandable" + _GroupName + Column); expandable?.AddCssClasses(monitorClasses + " mc-expandable"); }