Copied to clipboard

Flag this post as spam?

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


  • Phil Crowe 192 posts 256 karma points
    Oct 19, 2010 @ 11:28
    Phil Crowe
    0

    Get current node in custom datatype usercontrol

    I have created a custom datatype using the usercontrol wrapper. It uses a checkboxlist control and saves this list as a string with the selected values separated by commas. e.g 'phil,mike,jim,sarah'. if you reload this node in the content area of umbraco the checklist will be blank so i need to tick the appropriate boxes(those saved in the db as a string) i was going to do this by turning the string into a string array them looping through this to tick the checkboxes that need ticking. only problem is using Node Current = Node.GetCurrent(); doesnt seem to get the current node your looking at in the cms when its being used as a datatype. it ruturns null. how can i get a reference to this node i have my custom datatype on?

  • Phil Crowe 192 posts 256 karma points
    Oct 19, 2010 @ 11:37
    Phil Crowe
    1

    ive worked this out. 

            string nodeid = Request.QueryString["id"];

            Node Current = new Node(Convert.ToInt32(nodeid));

    the id of the node your looking at in the cms is stored in a querystring.

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Oct 19, 2010 @ 12:49
    Jeroen Breuer
    1

    Remember that in the node you can only get published data. It is recommended to use the Document object in a custom datatype usercontrol. More information: http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-a-node-and-a-document.

    Jeroen

  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Jun 25, 2013 @ 16:34
    Matt Barlow | jacker.io
    0

    The above link no longer works.

    Check these instead:

    Management APIs - 4.x

    Difference between node and document

    http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-node-and-document

    Document

    http://our.umbraco.org/documentation/Reference/Management/Documents/

     

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Jun 25, 2013 @ 17:19
    Jeroen Breuer
    0

    Since 4.10 you also have the IPublishedContent which you can use: http://our.umbraco.org/forum/developers/api-questions/37894-new-Dynamic(id)-and-new-Node(id)-equiv-in-v6?p=5#comment152555

    Your usercontrol can inherit from the UmbracoUserControl so you have all the helpers you need to get it.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies