Hey, how can I set a model value using razor in a view? If I understand correctly, doing: Model.valueName = newValue would do nothing, as it is not the reference, so how do I "get" the model, like in fx. Html.TextBoxFor();?
I ended up solving my issue with some javascript. I would rather not have, but this is definitely the simplest solution.
I understand why it's preferable to not change model values in views. I guess being a C# developer I tried to solve my issue using only C#, when javascript might have been the correct way.
Set a model value, from the corresponding view?
Hey, how can I set a model value using razor in a view? If I understand correctly, doing:
Model.valueName = newValue
would do nothing, as it is not the reference, so how do I "get" the model, like in fx. Html.TextBoxFor();?Hi Frederik.
What type is Model ? Is it a IPublishedContent instance or something custom ? With the first one you can't set the properties.
Also changing model values in views is something I'm not fan of, but that is food for another discussion.
Dave
I ended up solving my issue with some javascript. I would rather not have, but this is definitely the simplest solution.
I understand why it's preferable to not change model values in views. I guess being a C# developer I tried to solve my issue using only C#, when javascript might have been the correct way.
Thanks for your attention anyway :)
is working on a reply...