我想在for循环中添加具有唯一不同id的按钮。 像
<input id=1 type="submit" value="Remove" />
<input id=2 type="submit" value="Remove" />
<input id=3 type="submit" value="Remove" />
等等
@{
using (Html.BeginForm("Action", "Controller"))
{
for (int i = 0; i< 3; i++)
{
@Html.TextBoxFor(m => m[i].Title)
<input id={i} type="submit" value="Remove" />
}
<input type="submit" value="Submit" />
}
}
答案 0 :(得分:1)
你可以这样做:
@{
using (Html.BeginForm("Action", "Controller"))
{
for (int i = 0; i< 3; i++)
{
@Html.TextBoxFor(m => m[i].Title)
<input id="@i" type="submit" value="Remove" />
}
<input type="submit" value="Submit" />
}
}