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?
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?
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.
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
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/
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
is working on a reply...