Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello, I'm trying to save my IContent called child, but on this line(contentService.SaveAndPublish(child);) I get the following error: Object reference not set to an instance of an object.
Object reference not set to an instance of an object.
child.SetValue("navn", worker.Name.ToString(), "da-dk");
This is how I define my contentService:IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
And I'm finding the children like this:
IEnumerable<IContent> children = contentService.GetPagedChildren(filialsParent.Id, 0, 100, out totalChildren);
Can someone point out what is wrong here?
If you are using one of the Umbraco controllers (Surface, Mvc or Api controller) you should be able to use something like this:
var node = Services.ContentService.Create("name", parentId, contentTypeAlias);
The Services object is available in the controllers already and it includes singletons for all the services.
Have you tried with setting the same culture on the SaveAndPublish event?
But if you create a new multilangual content, then you cant SaveAndPublish it.
// Cannot save content with an empty name.
var content = _contentService.Create("contentName", 1025, "contentTypeAlias");
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted