Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Maton 387 posts 660 karma points
    Jul 25, 2012 @ 12:34
    Tom Maton
    0

    Error message when trying to create node in custom tree

    Hi All,

    I've managed to create my own section with my own tree and have the action of create and delete. When I click the create I get the standard modal window which is cool and I can enter the name of my new node, but when I click the create button I get the following error:

    Server Error in '/' Application.
    No parameterless constructor defined for this object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
    Source Error: 
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace: 

    [MissingMethodException: No parameterless constructor defined for this object.]
       System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
       System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117
       System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
       System.Activator.CreateInstance(Type type, Boolean nonPublic) +106
       umbraco.presentation.create.dialogHandler_temp.Create(String NodeType, Int32 TypeId, Int32 NodeId, String Text) +621
       umbraco.cms.presentation.create.controls.simple.sbmt_Click(Object sender, EventArgs e) +188
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

    Cant figure out what the hell is going on, if tried googling it, searching the forums and nothing.

    This is my code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Xml;
    using System.Xml.XPath;
    using umbraco.cms.businesslogic.web;
    using umbraco.cms.presentation.Trees;
    using umbraco.BusinessLogic.Actions;
    namespace BannerRotationManagement
    {
        public class BannerRotationManagementTree : BaseTree
        {   
            public BannerRotationManagementTree(string application)
                : base(application)
            {
                
            }
            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Icon = FolderIcon;
                rootNode.OpenIcon = FolderIconOpen;
                rootNode.NodeType = TreeAlias;
                rootNode.NodeID = "init";
            }
            
            protected override void CreateRootNodeActions(ref List<umbraco.interfaces.IAction> actions)
            {
                actions.Clear();
                actions.Add(ActionNew.Instance);
                actions.Add(ContextMenuSeperator.Instance);
                actions.Add(ActionSort.Instance);
                actions.Add(ContextMenuSeperator.Instance);
                actions.Add(ActionRefresh.Instance);
            }
            public override void Render(ref XmlTree tree)
            {
                Document[] banners = Document.GetChildrenForTree(base.m_id);
                
                foreach (Document banner in banners)
                {
                    var dNode = XmlTreeNode.Create(this);
                    dNode.NodeID = banner.Id.ToString();
                    dNode.Text = banner.Text;
                    dNode.Icon = "banner_design.png";
                    dNode.Action = "javascript:openContent(" + banner.Id + ")";
                    tree.Add(dNode);
                }
            }
            public override void RenderJS(ref System.Text.StringBuilder Javascript)
            {
                Javascript.Append(
                    @"
                        function openContent(id)
                        {
                            parent.right.document.location.href = editContent.aspx?id=' + id
                        }
                    ");
            }
        }
    }

    Any help would be greatly appreciated.

    Thanks,

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft