protected void EditDeleteButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            //prevent malicious deletes.
            if (_page.InstanceId == Webpage.RootNavigationId)
            {
                throw new InvalidOperationException("The portal root may not be deleted.");
            }
            if (_page.ParentInstanceId == Webpage.RootNavigationId)
            {
                throw new InvalidOperationException("Root pages (website roots) may not be deleted.");
            }

            if (!_page.IsAlias)
            {
                if (_page.Children.Count > 0)
                {
                    throw new InvalidOperationException("Pages with children may not be deleted.");
                }

                System.Collections.Generic.List <WebModuleInfo> modules = WebModule.GetModules(_instanceId);
                if (modules.Count > 0)
                {
                    throw new InvalidOperationException("Pages with modules may not be deleted.");
                }
            }

            _urlReferrer += _page.ParentInstanceId.Value;
            Webpage.DeleteWebpage(_instanceId);
            Response.Redirect(_urlReferrer);
        }
Esempio n. 2
0
        //also deletes webpage if it is empty.
        public static void DestroyMasterDetailItem(int moduleId)
        {
            //get the module object.
            WebModuleInfo module = WebModule.GetModule(moduleId);

            //get the container page of the module.
            WebpageInfo page = module.Webpage;

            //this cascades and destroys the MasterDetail associated items/resources.
            WebModule.DeleteModule(moduleId);

            //destory the item (this cascades down the resources).
            //MasterDetail_Item.Destroy(moduleId);

            //destory all associated item resources.
            //MasterDetail_ItemResource.Destroy(MasterDetail_ItemResource.Columns.ModuleId, moduleId);

            //if the page has no modules left on it, remove it also.
            if (null == page.Modules || page.Modules.Count == 0)
            {
                Webpage.DeleteWebpage(page.InstanceId);
            }
        }