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:
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:
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.
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.
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.
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.
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));
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));
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.
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:
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:
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:
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.
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.
I tested some more.
It appears that if you use a parsable NodeID:
You can use the ParentID property in the itaskreturnurlclass
but if you use a string NodeID ( not parsable to integer):
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
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.
That would depend on what kind of errors you get.
Could you elaborate on that?
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:
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 ??
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.
any example code suggestion
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.
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.
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:
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
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
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
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
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
is working on a reply...