More in this section
Forums / General Discussions / delete a page and its children

delete a page and its children

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Phil
    Phil avatar
    89 posts
    19 Oct 2010
    20 Jan 2011
    Link to this post
    I need to delete a page and all its children.  Right now I am not able to delete a pagenode.

    With this code:

            var manager = PageManager.GetManager();
            var guidCourseToDelete = new Guid(ddlCourses.SelectedValue);
            var pn = new PageNode("LessonBuilder1030/", guidCourseToDelete);
    // at this point pn.Id is the correct value

    I get the following error.  Please advise.  Thanks

    [InvalidOperationException: The instance is transient]
       DynamicModule.ns.Wrapped_OpenAccessPageProvider_dafc00828d0746a3be537e06dd250766.Delete(PageNode item) +249
       Telerik.Sitefinity.Modules.Pages.PageManager.Delete(PageNode item) +181
       LessonBuilder_UserControls_DeleteCourse.CmdDeleteCourse_Click(Object sender, EventArgs e) in c:\CurrentFiles\Projects\LessonBuilder1098\LessonBuilderApp\Sitefinity\LessonBuilder\UserControls\DeleteCourse.ascx.cs:39
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBefo
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    21 Jan 2011
    Link to this post
    Hello Phil,

    I am a little bit unsure that the approach you are taking has correct logic. You are first creating a new node and then trying to delete it right away. If you do not want to store the page node you should just not call save changes (this will rollback transaction). In case that you wish to delete a page it is recommended that you use the Fluent API to get the corresponding page node you wish to delete and delete it:
    public void DeletePage(string pageTitle)
           .Where(p => p.Page.Title == pageTitle)

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered