private void EditForm_OnBeforeSave(object sender, EventArgs e) { // Don't save shared layout object, update only necessary objects if ((EditedObjectType == EditedObjectTypeEnum.Layout) && radShared.Checked) { LayoutInfo li = EditedObject as LayoutInfo; // Get the current layout type PageTemplateLayoutTypeEnum layoutType = PageTemplateLayoutTypeEnum.PageTemplateLayout; PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplateInfo, DeviceProfileInfo, out layoutType); switch (layoutType) { case PageTemplateLayoutTypeEnum.PageTemplateLayout: case PageTemplateLayoutTypeEnum.SharedLayout: { int newLayoutId = ValidationHelper.GetInteger(drpLayout.Value, 0); // We need to save also page template if shared template is used if ((PageTemplateInfo != null) && (PageTemplateInfo.LayoutID != li.LayoutId)) { PageTemplateInfo.LayoutID = newLayoutId; PageTemplateInfo.Update(); } } break; case PageTemplateLayoutTypeEnum.DeviceSharedLayout: case PageTemplateLayoutTypeEnum.DeviceLayout: { // We need to save also template device layout if shared template is used PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, DeviceProfileID); if (deviceLayout != null) { deviceLayout.LayoutID = ValidationHelper.GetInteger(drpLayout.Value, 0); deviceLayout.LayoutCode = null; deviceLayout.LayoutCSS = null; deviceLayout.Update(); } } break; } ShowChangesSaved(); // Prevent from saving object EditForm.StopProcessing = true; } }
/// <summary> /// Handles the OnAfterAction event of the ObjectManager control. /// </summary> protected void ObjectManager_OnAfterAction(object sender, SimpleObjectManagerEventArgs e) { if ((e.ActionName == ComponentEvents.SAVE) || (e.ActionName == ComponentEvents.CHECKIN)) { if (EditForm.ValidateData()) { LayoutInfo li = EditedObject as LayoutInfo; if (radShared.Checked) { // Get the current layout type PageTemplateLayoutTypeEnum layoutType = PageTemplateLayoutTypeEnum.PageTemplateLayout; PageTemplateDeviceLayoutInfoProvider.GetLayoutObject(PageTemplateInfo, DeviceProfileInfo, out layoutType); switch (layoutType) { case PageTemplateLayoutTypeEnum.PageTemplateLayout: case PageTemplateLayoutTypeEnum.SharedLayout: { int newLayoutId = ValidationHelper.GetInteger(drpLayout.Value, 0); // We need to save also page template if shared template is used if ((PageTemplateInfo != null) && (PageTemplateInfo.LayoutID != li.LayoutId)) { PageTemplateInfo.LayoutID = newLayoutId; PageTemplateInfo.Update(); } } break; case PageTemplateLayoutTypeEnum.DeviceSharedLayout: case PageTemplateLayoutTypeEnum.DeviceLayout: { // We need to save also template device layout if shared template is used PageTemplateDeviceLayoutInfo deviceLayout = PageTemplateDeviceLayoutInfoProvider.GetTemplateDeviceLayoutInfo(TemplateID, DeviceProfileID); if (deviceLayout != null) { deviceLayout.LayoutID = ValidationHelper.GetInteger(drpLayout.Value, 0); deviceLayout.LayoutCode = null; deviceLayout.LayoutCSS = null; deviceLayout.Update(); } } break; default: break; } } // Register refresh script string refreshScript = ScriptHelper.GetScript("if ((wopener != null) && (wopener.RefreshPage != null)) {wopener.RefreshPage();}"); ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "pageTemplateRefreshScript", refreshScript); // Register preview refresh RegisterRefreshScript(); // Close if required if (ValidationHelper.GetBoolean(hdnClose.Value, false)) { ScriptHelper.RegisterStartupScript(Page, typeof(string), "CloseDialogPreviewScript", ScriptHelper.GetScript("CloseDialog();")); } // Load actual layout info (it was edited during saving by LayoutInfoProvider) if (li != null) { actualLayoutInfo = LayoutInfoProvider.GetLayoutInfo(li.LayoutId); } } // Hide warning after save MessagesPlaceHolder.WarningText = ""; } else if (e.ActionName == ComponentEvents.UNDO_CHECKOUT) { if (AllowTypeSwitching) { var url = RequestContext.CurrentURL; url = URLHelper.RemoveParameterFromUrl(url, "newshared"); url = URLHelper.RemoveParameterFromUrl(url, "oldshared"); url = URLHelper.AddParameterToUrl(url, "wopenerrefresh", "1"); Response.Redirect(url); } } else if (e.ActionName == ComponentEvents.CHECKOUT) { DisplayMessage(true); } switch (e.ActionName) { case ComponentEvents.SAVE: case ComponentEvents.CHECKOUT: case ComponentEvents.CHECKIN: case ComponentEvents.UNDO_CHECKOUT: if (DialogMode) { RegisterWOpenerRefreshScript(); } else if (dialog) { ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }")); } break; } if (!AllowTypeSwitching && (EditedObjectType == EditedObjectTypeEnum.Layout) && (e.ActionName != ComponentEvents.CHECKOUT) && !DialogMode) { ScriptHelper.RefreshTabHeader(Page, EditForm.EditedObject.Generalized.ObjectDisplayName); } // No save for checkout if (e.ActionName != ComponentEvents.CHECKOUT) { ShowChangesSaved(); } }