Copied to clipboard

Flag this post as spam?

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


  • Martin Lingstuyl 202 posts 379 karma points
    Feb 17, 2011 @ 12:32
    Martin Lingstuyl
    0

    Custom Sections, NodeId's and ITaskReturnUrl

    Hi,

    I've seen many people dealing with custom sections having the same problem I did: Names of nodes tend to repeat themselves when you revisit your custom section. To solve this one should use an absolutely unique nodeId like:

    XmlTreeNode sNode = XmlTreeNode.Create(this);
    sNode.NodeID = "1";

    Thats what I did. I created a set of nodes, and used ITaskReturnUrl classes to add delete and create tasks.

    Now the problem is I'm iterating my nodes from different databasetables and obviously I use the id-records of the database table as NodeId:

    XmlTreeNode sNode = XmlTreeNode.Create(this);
    sNode.NodeID = table1.id.ToString();
    XmlTreeNode sNode = XmlTreeNode.Create(this);
    sNode.NodeID = table2.id.ToString();

    Of course multiple databasetables all start their id's with 1, 2, 3 and so on. So the problem is I cannot create unique nodeId's like this. Hence I still have the repeating nodename problem....

    I tried prefixing the NodeID's with a unique string:

    XmlTreeNode sNode = XmlTreeNode.Create(this);
    sNode.NodeID = "table1" + table1.id.ToString();

    Now the NodeID is unique.

    The problem is now the delete functionality isnt working anymore. It seems to be trying to parse the nodeID to an Integer. But 'table11' obviously cannot be parsed to any integer, so the delete method fails, because it forgets which nodeID to delete.

    class CustomDeleteAndSaveTasks : umbraco.interfaces.ITaskReturnUrl
        {
            #region ITaskReturnUrl Members
    ...
            public int ParentID
            {
                get
                {
                    return _parentID;
                }
                set
                {
                    _parentID = value;
                }
            }

    It's the ParentID property which gets the parsed nodeID. So you can use it in a delete task. But in my case with the NodeID being: "table11" the ParentID turns to '0'.

     

    Does anyone know of a better way to still create unique nodeId's and still be able to delete records?

     

    Btw: the problem is in umbraco 4.5.2 I havent worked with 4.6 yet, so I dont know if its fixed or not.

     

     

     

  • Martin Lingstuyl 202 posts 379 karma points
    Feb 17, 2011 @ 17:37
    Martin Lingstuyl
    0

    I tested some more.

    It appears that if you use a parsable NodeID:

    sNode.NodeID = "123";

    You can use the ParentID property in the itaskreturnurlclass

    but if you use a string NodeID ( not parsable to integer):

    sNode.NodeID = "uniquenode123";

    The value gets put in the Alias Property in the itaskreturnurlclass

    So that seems to be an answer to my question. Dont know if it has drawbacks however. Any help would be appreciated

  • Max 144 posts 166 karma points
    May 29, 2012 @ 11:29
    Max
    0

    i have seperate umrbaco folder created i need seprate tasks to be assigned for indivudual tables in the custom multiple treee 

    as reference to this section 

    http://our.umbraco.org/forum/developers/extending-umbraco/7576-Custom-Section-with-multiple-trees-and-actions

     

    it works properly but when i try to asiign the tasks in the UI.xml file it does nto seem to work seprately it shows many errors any suggestion on how to do this. 

     

  • Martin Lingstuyl 202 posts 379 karma points
    May 29, 2012 @ 15:27
    Martin Lingstuyl
    0

    That would depend on what kind of errors you get.

    Could you elaborate on that?

     

     

  • Max 144 posts 166 karma points
    May 30, 2012 @ 08:24
    Max
    0

    Server Error in '/' Application.


    Input string was not in a correct format.

    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.FormatException: Input string was not in a correct format.

    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: 

    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9591147
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
       umbraco.cms.presentation.create.controls.simple.sbmt_Click(Object sender, EventArgs e) +100
       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 includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

     

     

    this is the error i get since i use :

    <usercontrol>/create/simple.ascx</usercontrol>

     

    also the delete gives error object nto set to a reference of an object

    is there anythign wrong with the Task class ??

     

  • Martin Lingstuyl 202 posts 379 karma points
    May 30, 2012 @ 14:41
    Martin Lingstuyl
    0

    Have you set the NodeID property on the node your right clicking?
    This should be a parsable number, as it is parsed to an integer. Thats probably what the error is for.

    Most of the time thats the problem. Try debugging your iTaskreturnUrl class and check out what the value is for ParentID and Alias.

     

     

     

  • Max 144 posts 166 karma points
    May 31, 2012 @ 06:15
    Max
    0

    any example code suggestion

     

  • Max 144 posts 166 karma points
    May 31, 2012 @ 06:27
    Max
    0

    this is my render method

       public override void Render(ref XmlTree tree)
            {

               

             
                   if (string.IsNullOrEmpty(this.NodeKey)) {
                    //Add the first level
                 
                    XmlTreeNode xNodeProfileKeywords = XmlTreeNode.Create(this);
                    xNodeProfileKeywords.NodeID = "manageIssues";
                    xNodeProfileKeywords.NodeType = "manageIssues";
                    xNodeProfileKeywords.Text = "IssuesMain";
                    xNodeProfileKeywords.Icon = "folder.gif";
                    xNodeProfileKeywords.HasChildren = true;
                    xNodeProfileKeywords.Source = this.GetTreeServiceUrl(xNodeProfileKeywords.NodeID);
                    xNodeProfileKeywords.Menu.Clear();
                    xNodeProfileKeywords.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodeProfileKeywords.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                 
                    tree.Add(xNodeProfileKeywords);


                    XmlTreeNode xNodeCompanies = XmlTreeNode.Create(this);
                    xNodeCompanies.NodeID = "manageIssueStatus";
                    xNodeCompanies.NodeType = "manageIssueStatus";
                    xNodeCompanies.Text = "IssuesStatus";
                    xNodeCompanies.Icon = "folder.gif";
                    xNodeCompanies.HasChildren = true;
                    xNodeCompanies.Source = this.GetTreeServiceUrl(xNodeCompanies.NodeID);
                    xNodeCompanies.Menu.Clear();
                    xNodeCompanies.Menu.AddRange(new List<IAction>() { ActionNew.Instance });

                  
                   xNodeCompanies.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodeCompanies);

                    XmlTreeNode xNodepriority = XmlTreeNode.Create(this);
                    xNodepriority.NodeID = "manageIssuesPriority";
                    xNodepriority.NodeType = "manageIssuesPriority";
                    xNodepriority.Text = "IssuesPriority";
                    xNodepriority.Icon = "folder.gif";
                    xNodepriority.HasChildren = true;
                    xNodepriority.Source = this.GetTreeServiceUrl(xNodepriority.NodeID);
                    xNodepriority.Menu.Clear();
                    xNodepriority.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodepriority.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });

                    tree.Add(xNodepriority);

                    XmlTreeNode xNodecat = XmlTreeNode.Create(this);
                    xNodecat.NodeID = "manageIssuesCategory";
                    xNodecat.NodeType = "manageIssuesCategory";
                    xNodecat.Text = "IssuesCategory";
                    xNodecat.Icon = "folder.gif";
                    xNodecat.HasChildren = true;
                    xNodecat.Source = this.GetTreeServiceUrl(xNodecat.NodeID);
                    xNodecat.Menu.Clear();
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodecat);

                   }
                   else if (this.NodeKey == "manageIssues")
                   {
                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesTable");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("ID").ToString();
                                                                
                           xNode.Text = reader.GetString("IssueName");
                           xNode.Icon = "docPic.gif";
                           xNode.Action = "javascript:openIssueTree(" + reader.GetInt("id").ToString() + ")";

                           tree.Add(xNode);

                       }
                    }
                      
                   else if (this.NodeKey == "manageIssueStatus")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssueStatus");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("StatusID").ToString();
                           xNode.Text = reader.GetString("IssueStatus");
                           xNode.Icon = "wall-brick.png";
                           xNode.Action = "javascript:openIssueStatus(" + reader.GetInt("StatusID").ToString() + ")";
                           xNode.Menu.Clear();
                       
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }
                  
                   }
                   else if (this.NodeKey == "manageIssuesPriority")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesPriority");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("PriorityID").ToString();
                           xNode.Text = reader.GetString("Priority");
                           xNode.Icon = "wand.png";
                           xNode.Action = "javascript:openIssuePriority(" + reader.GetInt("PriorityID").ToString() + ")";
                           xNode.Menu.Clear();
                           //xNode.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }

                   }
                   else if (this.NodeKey == "manageIssuesCategory")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesCategory");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("CategoryID").ToString();
                          
                           xNode.Text = reader.GetString("IssuesCategory");
                           xNode.Icon = "zone.png";
                           xNode.Action = "javascript:openIssuesCategory(" + reader.GetInt("CategoryID").ToString() + ")";
                           xNode.Menu.Clear();
                           //xNode.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }

                   }
                  
            }

     

    mu ui xml

    <nodeType alias="manageIssues">
            <header>IssuesMain</header>
             <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssueTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssueTask" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssueStatus">
            <header>IssueStatus</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssueStatusTasks" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssueStatusTasks" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssuesPriority">
            <header>IssuesPriority</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuePriorityTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuePriorityTask" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssuesCategory">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>

    my itask reurt url class sample

    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Collections.Generic;
    using umbraco.DataLayer;
    using umbraco.BusinessLogic;

    namespace IssuesUmbracoSection.Tasks
    {
        public class IssuesCategoryTask : umbraco.interfaces.ITaskReturnUrl
        {

            #region ITaskReturnUrl Members
            private string _returnUrl;
            public string ReturnUrl
            {
               
                get { return _returnUrl; }
            }

            #endregion

            #region ITask Members
            private string _alias;
            private int _parentID;
            private int _typeID;
            private int _userID;
            public string Alias
            {
                get
                {
                   
                    return _alias;
                }
                set
                {
                  
                    _alias = value;
                }
            }

            public bool Delete()
            {
               
                Application.SqlHelper.ExecuteNonQuery("delete from IssuesCategory where CategoryID = @CategoryID",
                               Application.SqlHelper.CreateParameter("@CategoryID", ParentID));

                return true;
            }

            public int ParentID
            {
                get
                {
                   
                    return _parentID;
                }
                set
                {
                 
                    _parentID = value;
                }
            }

            public bool Save()
            {
              
                int IdReturned = Application.SqlHelper.ExecuteScalar<int>
                               ("insert into IssuesCategory(IssuesCategory) values(@IssuesCategory);select @@Identity",
                       Application.SqlHelper.CreateParameter("@IssuesCategory", Alias));

                _returnUrl = "plugins/editIssuesCategory.aspx?id=" + IdReturned;

                return true;

            }

            public int TypeID
            {
                get
                {
                   
                    return _typeID;
                }
                set
                {
                  
                    _typeID = value;
                }
            }

            public int UserId
            {
               
                set { _userID = value; }
            }
        }
    }

            #endregion

           

    I get this error:while trying to delete

    Error handling action

    Object reference not set to an instance of an object.

  • Max 144 posts 166 karma points
    May 31, 2012 @ 06:37
    Max
    0

    this is my render method

       public override void Render(ref XmlTree tree)
            {

               

             
                   if (string.IsNullOrEmpty(this.NodeKey)) {
                    //Add the first level
                 
                    XmlTreeNode xNodeProfileKeywords = XmlTreeNode.Create(this);
                    xNodeProfileKeywords.NodeID = "manageIssues";
                    xNodeProfileKeywords.NodeType = "manageIssues";
                    xNodeProfileKeywords.Text = "IssuesMain";
                    xNodeProfileKeywords.Icon = "folder.gif";
                    xNodeProfileKeywords.HasChildren = true;
                    xNodeProfileKeywords.Source = this.GetTreeServiceUrl(xNodeProfileKeywords.NodeID);
                    xNodeProfileKeywords.Menu.Clear();
                    xNodeProfileKeywords.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodeProfileKeywords.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                 
                    tree.Add(xNodeProfileKeywords);


                    XmlTreeNode xNodeCompanies = XmlTreeNode.Create(this);
                    xNodeCompanies.NodeID = "manageIssueStatus";
                    xNodeCompanies.NodeType = "manageIssueStatus";
                    xNodeCompanies.Text = "IssuesStatus";
                    xNodeCompanies.Icon = "folder.gif";
                    xNodeCompanies.HasChildren = true;
                    xNodeCompanies.Source = this.GetTreeServiceUrl(xNodeCompanies.NodeID);
                    xNodeCompanies.Menu.Clear();
                    xNodeCompanies.Menu.AddRange(new List<IAction>() { ActionNew.Instance });

                  
                   xNodeCompanies.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodeCompanies);

                    XmlTreeNode xNodepriority = XmlTreeNode.Create(this);
                    xNodepriority.NodeID = "manageIssuesPriority";
                    xNodepriority.NodeType = "manageIssuesPriority";
                    xNodepriority.Text = "IssuesPriority";
                    xNodepriority.Icon = "folder.gif";
                    xNodepriority.HasChildren = true;
                    xNodepriority.Source = this.GetTreeServiceUrl(xNodepriority.NodeID);
                    xNodepriority.Menu.Clear();
                    xNodepriority.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodepriority.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });

                    tree.Add(xNodepriority);

                    XmlTreeNode xNodecat = XmlTreeNode.Create(this);
                    xNodecat.NodeID = "manageIssuesCategory";
                    xNodecat.NodeType = "manageIssuesCategory";
                    xNodecat.Text = "IssuesCategory";
                    xNodecat.Icon = "folder.gif";
                    xNodecat.HasChildren = true;
                    xNodecat.Source = this.GetTreeServiceUrl(xNodecat.NodeID);
                    xNodecat.Menu.Clear();
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodecat);

                   }
                   else if (this.NodeKey == "manageIssues")
                   {
                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesTable");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("ID").ToString();
                                                                
                           xNode.Text = reader.GetString("IssueName");
                           xNode.Icon = "docPic.gif";
                           xNode.Action = "javascript:openIssueTree(" + reader.GetInt("id").ToString() + ")";

                           tree.Add(xNode);

                       }
                    }
                      
                   else if (this.NodeKey == "manageIssueStatus")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssueStatus");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("StatusID").ToString();
                           xNode.Text = reader.GetString("IssueStatus");
                           xNode.Icon = "wall-brick.png";
                           xNode.Action = "javascript:openIssueStatus(" + reader.GetInt("StatusID").ToString() + ")";
                           xNode.Menu.Clear();
                       
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }
                  
                   }
                   else if (this.NodeKey == "manageIssuesPriority")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesPriority");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("PriorityID").ToString();
                           xNode.Text = reader.GetString("Priority");
                           xNode.Icon = "wand.png";
                           xNode.Action = "javascript:openIssuePriority(" + reader.GetInt("PriorityID").ToString() + ")";
                           xNode.Menu.Clear();
                           //xNode.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }

                   }
                   else if (this.NodeKey == "manageIssuesCategory")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesCategory");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("CategoryID").ToString();
                          
                           xNode.Text = reader.GetString("IssuesCategory");
                           xNode.Icon = "zone.png";
                           xNode.Action = "javascript:openIssuesCategory(" + reader.GetInt("CategoryID").ToString() + ")";
                           xNode.Menu.Clear();
                           //xNode.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                           xNode.Menu.Add(ActionDelete.Instance);
                           tree.Add(xNode);

                       }

                   }
                  
            }

     

    mu ui xml

    <nodeType alias="manageIssues">
            <header>IssuesMain</header>
             <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssueTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssueTask" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssueStatus">
            <header>IssueStatus</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssueStatusTasks" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssueStatusTasks" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssuesPriority">
            <header>IssuesPriority</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuePriorityTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuePriorityTask" />
            </tasks>
        </nodeType>
        <nodeType alias="manageIssuesCategory">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>

    my itask reurt url class sample

    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Collections.Generic;
    using umbraco.DataLayer;
    using umbraco.BusinessLogic;

    namespace IssuesUmbracoSection.Tasks
    {
        public class IssuesCategoryTask : umbraco.interfaces.ITaskReturnUrl
        {

            #region ITaskReturnUrl Members
            private string _returnUrl;
            public string ReturnUrl
            {
               
                get { return _returnUrl; }
            }

            #endregion

            #region ITask Members
            private string _alias;
            private int _parentID;
            private int _typeID;
            private int _userID;
            public string Alias
            {
                get
                {
                   
                    return _alias;
                }
                set
                {
                  
                    _alias = value;
                }
            }

            public bool Delete()
            {
               
                Application.SqlHelper.ExecuteNonQuery("delete from IssuesCategory where CategoryID = @CategoryID",
                               Application.SqlHelper.CreateParameter("@CategoryID", ParentID));

                return true;
            }

            public int ParentID
            {
                get
                {
                   
                    return _parentID;
                }
                set
                {
                 
                    _parentID = value;
                }
            }

            public bool Save()
            {
              
                int IdReturned = Application.SqlHelper.ExecuteScalar<int>
                               ("insert into IssuesCategory(IssuesCategory) values(@IssuesCategory);select @@Identity",
                       Application.SqlHelper.CreateParameter("@IssuesCategory", Alias));

                _returnUrl = "plugins/editIssuesCategory.aspx?id=" + IdReturned;

                return true;

            }

            public int TypeID
            {
                get
                {
                   
                    return _typeID;
                }
                set
                {
                  
                    _typeID = value;
                }
            }

            public int UserId
            {
               
                set { _userID = value; }
            }
        }
    }

            #endregion

           

    I get this error:while trying to delete

    Error handling action

    Object reference not set to an instance of an object.

  • Martin Lingstuyl 202 posts 379 karma points
    May 31, 2012 @ 09:46
    Martin Lingstuyl
    0

    Hi dude,

     

    I've taken a quick look at your code.
    I think this is the problem: xNodeProfileKeywords.NodeID = "manageIssues";

    This is not a parsable integer. I would make all those NodID's just numbers.

    -------------------

    I don't know what your doing here:

         int IdReturned = Application.SqlHelper.ExecuteScalar<int>
                               ("insert into IssuesCategory(IssuesCategory) values(@IssuesCategory);select @@Identity",
                       Application.SqlHelper.CreateParameter("@IssuesCategory", Alias));

     

    But as soon as you use a number for nodeID, the ParentID property contains the id your working with. I don't remember what the Alias will then contain, but maybe you should debug and try it out.

     

    This clear?

    Martin

     

  • Martin Lingstuyl 202 posts 379 karma points
    May 31, 2012 @ 09:48
    Martin Lingstuyl
    0

    Extra remark:

    It's not strange you get this error while trying to delete.

    The ParentID property is set to 0 when the NodeID cannot be parsed.

    So your actually trying to delete nothing, which of course errors out.

     

    Are you getting the nodes from dbase? My advice would be you use a ID column from dbase as a NodeID

     

    Martin

  • Max 144 posts 166 karma points
    May 31, 2012 @ 10:19
    Max
    0

    since its a multiple tree nodes

    on folder tree item has  children which are attached later

    i have solved it this way giving different types of NodeType in both the parents and child nodes

    like this


                    XmlTreeNode xNodecat = XmlTreeNode.Create(this);
                    xNodecat.NodeID = "manageIssuesCategory";
                    xNodecat.NodeType = "manageIssuesCategory";
                    xNodecat.Text = "IssuesCategory";
                    xNodecat.Icon = "folder.gif";
                    xNodecat.HasChildren = true;
                    xNodecat.Source = this.GetTreeServiceUrl(xNodecat.NodeID);
                    xNodecat.Menu.Clear();
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodecat);

     

    child nodes:

     else if (this.NodeKey == "manageIssuesCategory")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesCategory");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("CategoryID").ToString();
                           xNode.NodeType = "Category";
                           xNode.Text = reader.GetString("IssuesCategory");
                           xNode.Icon = "zone.png";
                           xNode.Action = "javascript:openIssuesCategory(" + reader.GetInt("CategoryID").ToString() + ")";
                           xNode.Menu.Clear();
                         
                           xNode.Menu.AddRange(new List<IAction>() { ActionDelete.Instance });
                           tree.Add(xNode);

                       }

    the UI

    <nodeType alias="manageIssuesCategory">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>
        <nodeType alias="Category">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>

     

    just use 2 node types different names

     

  • Max 144 posts 166 karma points
    May 31, 2012 @ 10:26
    Max
    0

    since its a multiple tree nodes

    on folder tree item has  children which are attached later

    i have solved it this way giving different types of NodeType in both the parents and child nodes

    like this


                    XmlTreeNode xNodecat = XmlTreeNode.Create(this);
                    xNodecat.NodeID = "manageIssuesCategory";
                    xNodecat.NodeType = "manageIssuesCategory";
                    xNodecat.Text = "IssuesCategory";
                    xNodecat.Icon = "folder.gif";
                    xNodecat.HasChildren = true;
                    xNodecat.Source = this.GetTreeServiceUrl(xNodecat.NodeID);
                    xNodecat.Menu.Clear();
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodecat);

     

    child nodes:

     else if (this.NodeKey == "manageIssuesCategory")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesCategory");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("CategoryID").ToString();
                           xNode.NodeType = "Category";
                           xNode.Text = reader.GetString("IssuesCategory");
                           xNode.Icon = "zone.png";
                           xNode.Action = "javascript:openIssuesCategory(" + reader.GetInt("CategoryID").ToString() + ")";
                           xNode.Menu.Clear();
                         
                           xNode.Menu.AddRange(new List<IAction>() { ActionDelete.Instance });
                           tree.Add(xNode);

                       }

    the UI

    <nodeType alias="manageIssuesCategory">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>
        <nodeType alias="Category">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>

     

    just use 2 node types different names

     

  • Max 144 posts 166 karma points
    May 31, 2012 @ 11:03
    Max
    0

    since its a multiple tree nodes

    on folder tree item has  children which are attached later

    i have solved it this way giving different types of NodeType in both the parents and child nodes

    like this


                    XmlTreeNode xNodecat = XmlTreeNode.Create(this);
                    xNodecat.NodeID = "manageIssuesCategory";
                    xNodecat.NodeType = "manageIssuesCategory";
                    xNodecat.Text = "IssuesCategory";
                    xNodecat.Icon = "folder.gif";
                    xNodecat.HasChildren = true;
                    xNodecat.Source = this.GetTreeServiceUrl(xNodecat.NodeID);
                    xNodecat.Menu.Clear();
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
                 
                    xNodecat.Menu.AddRange(new List<IAction>() { ActionRefresh.Instance });
                    tree.Add(xNodecat);

     

    child nodes:

     else if (this.NodeKey == "manageIssuesCategory")
                   {

                       IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from IssuesCategory");

                       while (reader.Read())
                       {
                           XmlTreeNode xNode = XmlTreeNode.Create(this);
                           xNode.NodeID = reader.GetInt("CategoryID").ToString();
                           xNode.NodeType = "Category";
                           xNode.Text = reader.GetString("IssuesCategory");
                           xNode.Icon = "zone.png";
                           xNode.Action = "javascript:openIssuesCategory(" + reader.GetInt("CategoryID").ToString() + ")";
                           xNode.Menu.Clear();
                         
                           xNode.Menu.AddRange(new List<IAction>() { ActionDelete.Instance });
                           tree.Add(xNode);

                       }

    the UI

    <nodeType alias="manageIssuesCategory">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>
        <nodeType alias="Category">
            <header>IssuesCategory</header>
            <usercontrol>/create/CreateControl.ascx</usercontrol>
            <tasks>
           <create assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
          <delete assembly="IssuesUmbracoSection" type="Tasks.IssuesCategoryTask" />
            </tasks>
        </nodeType>

     

    just use 2 node types different names

     

Please Sign in or register to post replies

Write your reply to:

Draft