我有这个代码
@if (ViewBag.TechnologyNames != null)
{
foreach (var technologyName in ViewBag.TechnologyNames)
{
if (@technologyName.TechnologyID == -1)
{
<div class="CheckBoxItem">
<input type="checkbox" name="option1" id="allTechnology" value="@technologyName.TechnologyID" checked="checked" />
@technologyName.Name
</div>
}
else
{
<input type="checkbox" name="option2" id="tech" value="@technologyName.TechnologyID" />
@technologyName.Name
}
}
}
我需要的是以某种方式将
@technologyName.TechnologyID
添加到id="tech"
的末尾id="tech_123"
我该怎么办?
谢谢!
最佳答案
尝试以下操作(基本上在属性周围添加括号):
<input type="checkbox" name="option2" id="tech_
@(technologyName.TechnologyID)" value="@technologyName.TechnologyID" />