+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / CreatePage and MovePage events

CreatePage and MovePage events

5 posts, 1 answered
  1. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    14 Oct 2010
    Link to this post
    Hi,

    I have some custom code executed on each page create/update event like this.
    CmsManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(OnCmsPageSave);

    In my method I check if CommandName is CreatePage or UpdatePage and do my custom actions there.

    It works great, but I also need to execute my code when page is moved in site tree.

    How can I do that? Is there another event to subscribe to ?

    Thanks,
    Aparaschivei Constantin

    forgot to mention, I am using Sitefinity 3.7.2057
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Oct 2010
    Link to this post
    Hello Constantin,

    When you move the page in the RadTreeView there is no event thrown. You cannot detect this action. You can use the RadTreeView event - NodeDrop

    You can add the event inside  Sitefinity\Admin\ControlTemplates\Pages\SiteMapPanel.ascx as shown below

    protected override void CreateChildControls()
    {
            base.CreateChildControls();
            this.SiteNavigation.NodeDrop += new RadTreeViewDragDropEventHandler(SiteNavigation_NodeDrop);
    }
     
    void SiteNavigation_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
        
    }

    You could also use the following java script function

    function TreeViewBeforeDropHandler(sender, eventArgs) {
           var sourceNode = eventArgs.get_sourceNode();
                           var destNode = eventArgs.get_destNode();
       }


    All the best,
    Ivan Dimitrov
    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
    Answered
  3. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    15 Oct 2010
    Link to this post
    <script type="text/C#" runat="server">
    protected override void CreateChildControls()
    {
            base.CreateChildControls();
            this.SiteNavigation.NodeDrop += new RadTreeViewDragDropEventHandler(SiteNavigation_NodeDrop);
    }
      
    void SiteNavigation_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
    }
    </script>

    Adding this code in the file you mentioned generates compilation errors at line 41
    Compiler Error Message: BC30205: End of statement expected.
     
    Source Error:
     
    Line 39:
    Line 40: <script type="text/C#" runat="server">
    Line 41: protected override void CreateChildControls()
    Line 42: {
    Line 43:         base.CreateChildControls();

    Am I missing something? Or am I doing something wrong?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Oct 2010
    Link to this post
    Hello Constantin,

    Here is the entire template

    <%@ Control Language="C#" %>
     
    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
    <%@ Register Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %>
     
    <script type="text/javascript">
     
        function TreeViewBeforeDropHandler(sender, eventArgs) {
            alert('test');
        }
    </script>
     
    <script type="text/C#" runat="server">
     
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            this.SiteNavigation.NodeDrop += new RadTreeViewDragDropEventHandler(SiteNavigation_NodeDrop);
        }
         
        void SiteNavigation_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
        {
         
        }
    </script>
     
    <asp:LinkButton ID="createBtn" CommandName="New" CssClass="CmsButLeft new" runat="server">
        <strong class="CmsButRight light"><asp:Literal runat="server" Text="<%$Resources:CreateAPage %>"></asp:Literal></strong>
    </asp:LinkButton>
    <h2 id="sitemap"><asp:Literal runat="server" Text="<%$Resources:SiteMap %>"></asp:Literal></h2>
    <div class="sitemapTree">
    <telerik:RadTreeView ID="SiteNavigation"   EnableDragAndDropBetweenNodes="true" EnableDragAndDrop="true"  runat="server" Width="190"></telerik:RadTreeView></div>
    <div id="mess"><!-- -->
    <sfWeb:MessageControl runat="server" ID="message">
        <ItemTemplate>
            <asp:Literal runat="server" ID="messageText"></asp:Literal>
        </ItemTemplate>
    </sfWeb:MessageControl>
    </div>
    <div id="smWrapper" style="display:none;">
    <div class="SiteMapTools">
    <h3><asp:Literal runat="server" Text="<%$Resources:SelectAPageAboveAnd %>"></asp:Literal>:</h3>
        <ul>
            <li class="PageDefault">
                <asp:LinkButton ID="LinkButton1" CommandName="HomePage" Text="<%$Resources:SetHomePage %>" ToolTip="<%$Resources:SetHomePageTooltip %>" runat="server"><asp:Literal runat="server" Text="<%$Resources:SetAsHomePage %>"></asp:Literal></asp:LinkButton>
            </li>
            <li class="PageDuplicate">
                <asp:LinkButton ID="LinkButton5" CommandName="Duplicate" Text="<%$Resources:DuplicatePage %>" ToolTip="<%$Resources:DuplicatePageToolTip %>" runat="server"><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:DuplicatePage %>"></asp:Literal></asp:LinkButton>
            </li>
            <li class="PageUp">
                <asp:LinkButton ID="LinkButton2" CommandName="MoveUp" Text="<%$Resources:MovePageUp %>" ToolTip="<%$Resources:MovePageUpTooltip %>" runat="server"></asp:LinkButton>
            </li>
            <li class="PageDown">
                <asp:LinkButton ID="LinkButton3" CommandName="MoveDown" Text="<%$Resources:MovePageDown %>" ToolTip="<%$Resources:MovePageDownTooltip %>" runat="server"></asp:LinkButton>
            </li>
            <li class="PageDelete">
                <asp:LinkButton ID="LinkButton4" CommandName="Delete" Text="<%$Resources:Delete %>" ToolTip="<%$Resources:DeleteTooltip %>" runat="server"></asp:LinkButton>
            </li>
        </ul>
    </div>
    </div>

    You can find more information about the error here.


    Kind regards,
    Ivan Dimitrov
    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
  5. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    15 Oct 2010
    Link to this post
    That is exactly what I need.
    Thanks.
Register for webinar
5 posts, 1 answered