Reputation: 45
I'm trying to pass two strings as parameters for constructor which is already embedded inside attribute with double quotes:
<select asp-for="Employee.StockId" asp-items="@new SelectList(Model.Stocks, "Id", "Name")" class="form-control"></select>
I've tried escaping with backslashes or @
but still no success.
Edit: So, there are two options which actually worked:
asp-items='@new SelectList(Model.Stocks, "Id", "Name")'
asp-items="@new SelectList(Model.Stocks,@{"Id"}, @{"Name"})"
Upvotes: 4
Views: 2012
Reputation: 30545
Try This:
asp-items='@new SelectList(Model.Stocks, "Id", "Name")'
Upvotes: 4