Copied to clipboard

Flag this post as spam?

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


  • Dirk 13 posts 33 karma points
    Nov 02, 2011 @ 12:32
    Dirk
    0

    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?

  • Rich Green 2246 posts 4008 karma points
    Nov 02, 2011 @ 12:48
    Rich Green
    0

    Hey Dirk,

    If I understood you correctly you can just use node datanode = new Node(Request.QueryString["id"]);

    Rich

  • Dirk 13 posts 33 karma points
    Nov 02, 2011 @ 14:32
    Dirk
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 02, 2011 @ 14:36
    Jeroen Breuer
    0

    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

  • Dirk 13 posts 33 karma points
    Nov 02, 2011 @ 15:13
    Dirk
    0

    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. :-)

Please Sign in or register to post replies

Write your reply to:

Draft