I am using an editortemplate, I have shown partial code below. The script tag repeats for each of the rows being rendered by the partial view.
Is there a way to get the script tag into the page header, or at the very least have it included in the page only once?
I would like the code in the partial view as that is where it truly belongs.
@* DisplayTemplates/contact.cshtml *@
@model Online.Web.Contacts.Contact
<script id="xxx">
stuff here.
</script>
<tr>
<td>@Html.EditorFor(x => x.FirstName)</td>
</tr>
You could try this:
@model IEnumerable<Online.Web.Contacts.Contact>
<script id="xxx">
stuff here.
</script>
@Html.EditorForModel()
and then another editor template for a single contact:
@model Online.Web.Contacts.Contact
<tr>
<td>@Html.EditorFor(x => x.FirstName)</td>
</tr>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With