But when I call the create a new item from the subroot items I get the following message
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.
First off, looks like you are trying to Parse a string to an integer but something goes wrong - maybe your string is not a number (maybe because you are not hitting your usercontrol)?
Have you tried debugging to see what goes on in your usercontrol? And whether your Create action hits the right usercontrol (this is the standard umbraco create control right: <usercontrol>/create/simple.ascx</usercontrol>)?
Does the create action actually work on the rootnode or is it both root and subnode thats not working?
Thanks for your reply, it really helped to solve the problem. Underneath my solution.
I gave the NodeID's for my second level items a string value because the rootnode has the value "init'. So I didn't think it should cause an issue. But you were right that this caused the issue. To make a workaround I decided to create a new page, to handle the creation of an new item.
Glad I could help. Please mark one of the answers as solution, so others can see there is a solution to this issue - and thanks for sharing your solution ;)
Custom Section with multiple trees and actions
I created a custom section which loads a tree. The root tree has two nodes.
The create action on the two main nodes should preform a seperate action. So far I have this:
public override void Render(ref XmlTree tree) {
if (string.IsNullOrEmpty(this.NodeKey)) {
//Add the first level
XmlTreeNode xNodeProfileKeywords = XmlTreeNode.Create(this);
xNodeProfileKeywords.NodeID = "manageProfileKeywords";
xNodeProfileKeywords.NodeType = "manageProfileKeywords";
xNodeProfileKeywords.Text = "Profiel sleutelwoorden";
xNodeProfileKeywords.Icon = "folder.gif";
xNodeProfileKeywords.HasChildren = true;
xNodeProfileKeywords.Source = this.GetTreeServiceUrl(xNodeProfileKeywords.NodeID);
xNodeProfileKeywords.Menu.Clear();
xNodeProfileKeywords.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
tree.Add(xNodeProfileKeywords);
XmlTreeNode xNodeCompanies = XmlTreeNode.Create(this);
xNodeCompanies.NodeID = "manageStringTranslations";
xNodeCompanies.NodeType = "manageStringTranslations";
xNodeCompanies.Text = "Vertaalbare tekst";
xNodeCompanies.Icon = "folder.gif";
xNodeCompanies.HasChildren = true;
xNodeCompanies.Source = this.GetTreeServiceUrl(xNodeCompanies.NodeID);
xNodeCompanies.Menu.Clear();
xNodeCompanies.Menu.AddRange(new List<IAction>() { ActionNew.Instance });
tree.Add(xNodeCompanies);
} else if (this.NodeKey == "manageProfileKeywords") {
using (MyHypothekerUmbracoEntities rep = new MyHypothekerUmbracoEntities()) {
var allProfileKeywords = rep.ProfileKeywordSet.OrderBy(pk => pk.Keyword);
foreach (var profileKeyword in allProfileKeywords) {
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = profileKeyword.ProfileKeywordID.ToString();
xNode.Text = profileKeyword.Keyword;
xNode.Icon = "hyp_profiles_16.png";
xNode.Action = "javascript:openProfileKeyword('" + xNode.NodeID + "')";
tree.Add(xNode);
}
}
} else if (this.NodeKey == "manageStringTranslations") {
using (MyHypothekerUmbracoEntities rep = new MyHypothekerUmbracoEntities()) {
var allReplacements = rep.StringReplacementItemSet.OrderBy(r => r.StringReplacementKey);
foreach (var replacement in allReplacements) {
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = replacement.StringReplacementId.ToString();
xNode.Text = replacement.StringReplacementKey;
xNode.Icon = "hyp_profiles_16.png";
xNode.Action = "javascript:openStringTranslation('" + xNode.NodeID + "')";
tree.Add(xNode);
}
}
}
}
In the UI.XML I tried to add this code to make teh magic happen:
<nodeType alias="manageProfileKeywords">
<header>Profile keywords</header>
<usercontrol>/create/simple.ascx</usercontrol>
<tasks>
<create assembly="TamTam.Umbraco.Exensions" type="Sections.Custom.Tasks.ProfileKeywordsTasks" />
<delete assembly="TamTam.Umbraco.Exensions" type="Sections.Custom.Tasks.ProfileKeywordsTasks" />
</tasks>
</nodeType>
<nodeType alias="manageStringTranslations">
<header>String translations</header>
<usercontrol>/create/simple.ascx</usercontrol>
<tasks>
<create assembly="TamTam.Umbraco.Exensions" type="Sections.Custom.Tasks.StringTranslationsTasks" />
<delete assembly="TamTam.Umbraco.Exensions" type="Sections.Custom.Tasks.StringTranslationsTasks" />
</tasks>
</nodeType>
But when I call the create a new item from the subroot items I get the following message
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:
Anyone has any idea if this is the right way to go, what I am doing wrong or have another idea.
Hi Frank,
First off, looks like you are trying to Parse a string to an integer but something goes wrong - maybe your string is not a number (maybe because you are not hitting your usercontrol)?
Have you tried debugging to see what goes on in your usercontrol? And whether your Create action hits the right usercontrol (this is the standard umbraco create control right: <usercontrol>/create/simple.ascx</usercontrol>)?
Does the create action actually work on the rootnode or is it both root and subnode thats not working?
- Morten
Hi again,
Here is the code that is throwing the exception in the simple.ascx usercontrol:
Thought it might help you in the right direction - as you can se the "nodeId" querystring is parsed to an integer, which seems to fail.
Could it be these two nodes that are causing you problems (?):
xNodeProfileKeywords.NodeID = "manageProfileKeywords";
xNodeCompanies.NodeID = "manageStringTranslations";
- Morten
Hi Morten,
Thanks for your reply, it really helped to solve the problem. Underneath my solution.
I gave the NodeID's for my second level items a string value because the rootnode has the value "init'. So I didn't think it should cause an issue. But you were right that this caused the issue. To make a workaround I decided to create a new page, to handle the creation of an new item.
So my UI.xml will look something like this:
I copied the code from simple.ascx.cs to my dbitem.ascx.cs and changed the code to:
This will make everything work as it should.
Maybe this code could be placed in the next release, to fix these kind of problems.
Thanks agian.
- Frank
Hi Frank,
Glad I could help.
Please mark one of the answers as solution, so others can see there is a solution to this issue - and thanks for sharing your solution ;)
- Morten
what about UmbracoApp table setting do you need to do anythign regarding that
Hi I created my own Control However the delete function is not working it gives me object not set to a refence of an object error.
how to solve this
the delete is not working it give me this error
Error handling action
Object reference not set to an instance of an object
is working on a reply...