I am trying to create a very simple survey form, and I thought about using it instead of a razor instead of external control.
I created a form that lists one question and a list of answers, and when we click the submit button, we go to a page that calls a razor script that processes the results.
What I want to do is to look through all the answers and increase the counter by one. There is a numerical property called “Counter” for each “Response” object.
However, this continues to fail. If I do this:
var objAnswer = @Model.NodeById(Int32.Parse(submittedAnswer));
objAnswer.getProperty("Counter").Value++;
or similar methods, they all fail. It is strange that objAnswer.getProperty ("Counter") contains a number, but when I try to set it, I get this error:
umbraco.MacroEngines.DynamicNull' does not contain a definition for 'Value'
I get I also tried using
Document post = new Document(objAnswer.Id);
post.Publish(user);
but it also fails.
Is there an easy way to achieve this?
The answer is:
Document doc = new Document(objAnswer.Id);
doc.getProperty("counter").Value = 34;
umbraco.BusinessLogic.User author = umbraco.BusinessLogic.User.GetUser(0);
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
This does not mean that the property should be lowercase.
source
share