Oct 17, 2018 11:18 AM|ASKemp|LINK
Thanks for the reply. My example is perhaps too simple.
I have a number of form controls that will be used elsewhere, e.g. user lists, status types, site lists etc. that I've implemented as view components. I can call them fine but I want their form id and name values to be dynamic and filled from the model underlying
the view component rather than hard coded.
My first attempt is to pass the form id and name values via the call to the component - I'm using tag helpers. This is fine and works as expected other than it is also, in effect, hard coding the id and name since, if the model changes, then these values
will not update to reflect the changes.
If I include the form controls directly in the form then I can simply use the asp-for tag helper to generate the name and id for the control from the model. I want, if it's possible, to be able to pass this value/object via the tag helper, into the view
component, it's underlying model and thereby reference it in the view code of the view component.
I've seen reference to ModelExpression which "describes an expression passed to a tag helper" - wondering if this or something similar can be used to effectively pass the reference through or, alternatively, if I can evaluate the value of asp-for in via
parent view and then pass it to the view component as a plain string.
Any help appreciated.