/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void pageTemplatesGrid_OnAction(string actionName, object actionArgument) { int widgetId = Convert.ToInt32(actionArgument); switch (actionName) { case "delete": // Check 'Modify' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.widget", "Modify")) { RedirectToAccessDenied("cms.widget", "Modify"); } // delete PageTemplateInfo object from database WidgetInfoProvider.DeleteWidgetInfo(widgetId); // Refresh tree ltlScript.Text = ScriptHelper.GetScript("RefreshAdditionalContent();"); break; case "clone": string scriptDialog = "modalDialog('" + URLHelper.ResolveUrl("~/CMSModules/Widgets/Dialogs/Widget_Clone.aspx") + "?widgetid=" + widgetId + "&reloadAll=0','WidgetClone', 500, 250);"; ltlScript.Text = ScriptHelper.GetScript(scriptDialog); break; } }
/// <summary> /// Deletes widget. Called when the "Delete widget" button is pressed. /// Expects the CreateWidget method to be run first. /// </summary> private bool DeleteWidget() { // Get the widget WidgetInfo deleteWidget = WidgetInfoProvider.GetWidgetInfo("MyNewWidget"); // Delete the widget WidgetInfoProvider.DeleteWidgetInfo(deleteWidget); return(deleteWidget != null); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void pageTemplatesGrid_OnAction(string actionName, object actionArgument) { int widgetId = Convert.ToInt32(actionArgument); switch (actionName) { case "delete": // Check 'Modify' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.widget", "Modify")) { RedirectToAccessDenied("cms.widget", "Modify"); } // delete PageTemplateInfo object from database WidgetInfoProvider.DeleteWidgetInfo(widgetId); // Refresh tree ltlScript.Text = ScriptHelper.GetScript("RefreshAdditionalContent();"); break; } }
/// <summary> /// Handles delete action. /// </summary> /// <param name="eventArgument">Objecttype(widget or widgetcategory);objectid</param> public void RaisePostBackEvent(string eventArgument) { string[] values = eventArgument.Split(';'); if ((values != null) && (values.Length > 2)) { string action = values[0]; int id = 0; int parentId = 0; string script = String.Empty; WidgetCategoryInfo wci = null; switch (action) { case "newwidget": id = ValidationHelper.GetInteger(values[1], 0); parentId = ValidationHelper.GetInteger(values[2], 0); // Create new widget of selected type WidgetInfo wi = NewWidget(id, parentId); if (wi != null) { // Select parent node after delete wci = WidgetCategoryInfoProvider.GetWidgetCategoryInfo(parentId); if (wci != null) { script = SelectAtferLoad(wci.WidgetCategoryPath + "/" + wi.WidgetName, wi.WidgetID, "widget", wi.WidgetCategoryID); } } break; // Delete widget or widget category case "delete": id = ValidationHelper.GetInteger(values[2], 0); parentId = ValidationHelper.GetInteger(values[3], 0); switch (values[1]) { case "widget": WidgetInfoProvider.DeleteWidgetInfo(id); break; case "widgetcategory": try { WidgetCategoryInfoProvider.DeleteWidgetCategoryInfo(id); } catch (Exception ex) { // Make alert with exception message, most probable cause is deleting category with subcategories script = String.Format("alert('{0}');\n", ex.Message); // Current node stays selected parentId = id; } break; } // Select parent node after delete wci = WidgetCategoryInfoProvider.GetWidgetCategoryInfo(parentId); if (wci != null) { script = SelectAtferLoad(wci.WidgetCategoryPath + "/", parentId, "widgetcategory", wci.WidgetCategoryParentID) + script; } break; } widgetTree.ReloadData(); ltlScript.Text += ScriptHelper.GetScript(script); } }