Although all the posts were very helpful, they did not meet the specifications, which to be true weren't very exact from my side.
I've came up with this soulution:
var salesAction = new PageSalesAction(content);
salesAction.LastNameOverwrite = resultLastName;
salesAction.SalutationOverwrite = resultSalutation;
contentRequest.PublishedContent = salesAction;
I'm creating a new Page and pass the content from the ContentFinder. Now I created a new Model which includes the getter and setter for the properties:
public partial class PageSalesAction
{
public string LastNameOverwrite { get; internal set; }
public string SalutationOverwrite { get; internal set; }
}
In my .cshtml View, which is a PageSalesAction, I can get the data via @Model.LastNameOverwrite and @Model.SalutationOverwrite
ContentFinder get Property from Node and set Value (string)
If I want to acces a Property I'll have to get the node:
then I have to get the property itself:
But now how can I set the Value to "Hello World". The Following variant doesn't work:
Can someone help me with this problem?
So I figured I'll have to solve that different, beacuse the Property gets it's value from the database.
Maybe I'm wrong and the Value can be set, I'd be looking forward to heare from you.
I'm stilll figuring out how to do it, so if there are any other ways, I'd appreciate to heare from you :).
Greetings Linden
Hi,
You need to do something like.
content.SetValue("property",value)
Hi Reddick
Thanks for answering, but sadly the setValue() doesn't exist on content, because it's a IPublishedContent...
Hej Linden,
The IPublishedContent is a kind of a read only. So there is no way to set the propertyValue.
What you can do is DI IContentService into your controller, do like this
you can read more about the contentService here https://our.umbraco.com/documentation/Reference/Management/Services/ContentService/
Or an old post I found on the same question: https://our.umbraco.com/forum/using-umbraco-and-getting-started/96142-setvalue-for-ipublishedcontent
Although all the posts were very helpful, they did not meet the specifications, which to be true weren't very exact from my side.
I've came up with this soulution:
I'm creating a new Page and pass the content from the ContentFinder. Now I created a new Model which includes the getter and setter for the properties:
In my .cshtml View, which is a PageSalesAction, I can get the data via
@Model.LastNameOverwrite
and@Model.SalutationOverwrite
Thanks everyone for you inputs!
Greetings Linden
is working on a reply...