What I want to do is to have a datatype that processes an amount of data from the children of the node where it is used. Right now I have something like this:
public partial class usercontrols_Stat : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
public object value { get { throw new NotImplementedException(); }
set { if (value != null) { Node datanode = new Node(1061); int nodecount = datanode.Children.Count; int mancount = 0; int vrouwcount= 0; int jongcount = 0; int oudcount = 0;
LabelCount.Text = nodecount.ToString(); foreach (Node child in datanode.Children) { if (child.GetProperty("geslacht").Value == "Man") mancount += 1; if (child.GetProperty("geslacht").Value == "Vrouw") vrouwcount += 1; if (int.Parse(child.GetProperty("leeftijd").Value) >= int.Parse(datanode.Parent.GetProperty("minimumLeeftijdVolwassene").Value)) oudcount += 1;
else { jongcount += 1; } }
//fill the labels
}}}}
But what I really want to do here is to use something like Node.GetCurrent(), but that doesn't work because the control is used in the backoffice on a documenttype. Any ideas what to do here?
Node datanode = new Node(Request.QueryString["id"]); Node datanode = new Node(Request["id"])
I'm creating a custom datatype with the usercontrol wrapper. I want to acces the "current node" from the content section in the backoffice.
The idea is that users can create their own surveys in the backoffice and that they can see statistics of the members who took the survey, without having to export the data to excel or anything that requires any sort of effort or skill. :-) They just have to click on the folder "Participants" and see all the info inside the Umbraco backoffice.
Right now I got it working, but only if I specify the nodeID manually in the sourcecode.
UsercontrolWrapper, calling statistics dynamically
What I want to do is to have a datatype that processes an amount of data from the children of the node where it is used. Right now I have something like this:
public partial class usercontrols_Stat : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
{
protected void Page_Load(object sender, EventArgs e) { }
public object value { get { throw new NotImplementedException(); }
set
{
if (value != null)
{
Node datanode = new Node(1061);
int nodecount = datanode.Children.Count;
int mancount = 0;
int vrouwcount= 0;
int jongcount = 0;
int oudcount = 0;
LabelCount.Text = nodecount.ToString();
foreach (Node child in datanode.Children)
{
if (child.GetProperty("geslacht").Value == "Man") mancount += 1;
if (child.GetProperty("geslacht").Value == "Vrouw") vrouwcount += 1;
if (int.Parse(child.GetProperty("leeftijd").Value) >= int.Parse(datanode.Parent.GetProperty("minimumLeeftijdVolwassene").Value)) oudcount += 1;
else { jongcount += 1; }
}
//fill the labels
}}}}
But what I really want to do here is to use something like Node.GetCurrent(), but that doesn't work because the control is used in the backoffice on a documenttype. Any ideas what to do here?
Hey Dirk,
If I understood you correctly you can just use node datanode = new Node(Request.QueryString["id"]);
Rich
Hi Rich,
It doesn't work. I tried stuff like this:
Node datanode = new Node(Request.QueryString["id"]);
Node datanode = new Node(Request["id"])
I'm creating a custom datatype with the usercontrol wrapper.
I want to acces the "current node" from the content section in the backoffice.
The idea is that users can create their own surveys in the backoffice and that they can see statistics of the members who took the survey, without having to export the data to excel or anything that requires any sort of effort or skill. :-)
They just have to click on the folder "Participants" and see all the info inside the Umbraco backoffice.
Right now I got it working, but only if I specify the nodeID manually in the sourcecode.
You can do it like this:
Document document =
new Document(Convert.ToInt32(HttpContext.Current.Request.QueryString["id"]));
See this wiki for more info: http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-a-node-and-a-document
Jeroen
Okay, I can work with that.
On a related topic: I still don't understand why these lines work:
int integer = int.Parse(node.GetProperty("property").Value;
string astring = document.getProperty("property").Value;
But this doesn't:
int integer = int.Parse(document.getProperty("property").Value;
Provided that the property could parse correctly.
Anyway, thanks a lot. :-)
is working on a reply...