Now you can add the contentpicker to a control collection, oninit (in this case a placeholder with id phContentPicker)
dataExtractor = new DataExtractor(); contentPicker = new umbraco.editorControls.pagePicker(dataExtractor); phContentPicker.Controls.Add(contentPicker);
Initialization of the picker works fine for me. I create the picker and i create the extractor and set the value of the extractor and on the admin side it gets populated correctly. Right now though, i cant seem to get the value after i change the value in the picker? i keep getting null reference exceptions whenever i use dataextractor.value after changing the value of the picker
I got a cast error, saying that my datatype was pagePicker, eventhough the database said the ID 1034 is the ContentPicker, anyone who can help with that?
After that I tried the example above, and got the mediapicker, but I cannot seem to get the value after I change the selection.
In either case I would like to be able to run a Javascript function after the select has been done, any input about how that could be done?
Where the definition is in the top of the class, and the rest in the onInit override.
I can assign a value to it, and it has that when being drawn, but if I change the value, or just pushes a button which does a postback, then when I try to get the value in the onclick method I get "Object reference not set to an instance of an object."
RE: Tim Gayssens' post. When the page is submitted, how do you get the value from the DataExtractor? On Postback the DataExtractor is being re-created and it's value is Null.
I am getting null object reference error when I am trying to set value, I have tried just read contentpicker and the above method , but I don't get the value
Mediapicker / contentpicker in edit page in custom section.
Hi,
I use Umbraco v. 4.0.2.1.
I have made a custom section, that loads data from a custom table. Rendering of the tree and editing of data works fine.
Now I want to relate the entities in the custom table to 'standard' umbraco content/media.
How can I insert a contentpicker or a mediapicker in my custom 'edit custom entity' web form (so I can save the selected node id in the custom table)?
Best regards
Ulrik
Comment author was deleted
First you'll need a class that inherits from IData,
Then add these:
Now you can add the contentpicker to a control collection, oninit (in this case a placeholder with id phContentPicker)
Wonderful :-)
And with the mediapicker I suppose it would be something like:
But how do I get the selected node id?
Best regards
Ulrik
Hi,
I have succesfully added the above code to the edit page of my custom tree.
But can anyone tell me, how a field that contains media data, should be formatted in a the custom table?
Why didn't you simply use the ContentPicker control (umbracon.controls.ContentPicker).. this would give you the media tree in a dialog.
Initialization of the picker works fine for me. I create the picker and i create the extractor and set the value of the extractor and on the admin side it gets populated correctly. Right now though, i cant seem to get the value after i change the value in the picker? i keep getting null reference exceptions whenever i use dataextractor.value after changing the value of the picker
anyone experience this?
I have tried this aswell..
But I wanted to use the ContentPicker, but my problem was when I did the following:
I got a cast error, saying that my datatype was pagePicker, eventhough the database said the ID 1034 is the ContentPicker, anyone who can help with that?
After that I tried the example above, and got the mediapicker, but I cannot seem to get the value after I change the selection.
In either case I would like to be able to run a Javascript function after the select has been done, any input about how that could be done?
Hi Jacob,
Here you can find a good example how you can add the media picker to a custom section: http://our.umbraco.org/forum/developers/extending-umbraco/13518-implement-improved-mediapicker-c. It also places the datatype on a custom page.
Jeroen
Hey, allready tried those examples, and it is not an option for me to alter the souce code of Umbraco.
I got to the point where I have the mediapicker with:
Where the definition is in the top of the class, and the rest in the onInit override.
I can assign a value to it, and it has that when being drawn, but if I change the value, or just pushes a button which does a postback, then when I try to get the value in the onclick method I get "Object reference not set to an instance of an object."
Have I forgotten somthing obvious?
RE: Tim Gayssens' post. When the page is submitted, how do you get the value from the DataExtractor? On Postback the DataExtractor is being re-created and it's value is Null.
I've just worked out this simple solution based on a combination of the various comments in this post. (I'm using 4.7.2)
I've got a placeholder (phMedia) in my user control where I want the media picker.
In my 'Page_Load' function I define the following:
To set the media picker to display the stored value:
To save the selected value in my 'save_Click' function:
I hope this helps someone else!
I am getting null object reference error when I am trying to set value, I have tried just read contentpicker and the above method , but I don't get the value
please help
is working on a reply...