In the controller code below I have an image coming from a media picker and a string from a textbox, both name exactly as they are below.
When I put a breakpoint on the code I can get the image url no problem but the description is always null, even though I can see it when I drill down in the model. Should I be doing it differently for a string value?
var mainImage = page.Value<IPublishedContent>("mainImage");
var description = page.Value<IPublishedContent>("description");
model.Add(new MyModel(mainImage.Url, description.ToString());
text from custom content always null in my code
In the controller code below I have an image coming from a media picker and a string from a textbox, both name exactly as they are below.
When I put a breakpoint on the code I can get the image url no problem but the description is always null, even though I can see it when I drill down in the model. Should I be doing it differently for a string value?
Hi Damion
Yes, Description should be another type, is it multiline text box property editor? RTE?
Thanks,
Alex
Try "string".
you mean string instead of a var? That results in the error
'Cannot implicitly convert type 'Umbraco.Core.Models.PublishedContent.IPublishedContent' to 'string''
no, like this:
excellent, thanks!
is working on a reply...