简体   繁体   中英

How do I escape quotes inside attribute in razor pages

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"})"

尝试这个:

asp-items='@new SelectList(Model.Stocks, "Id", "Name")'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM