我不知道为什么,但是当我运行应用程序时,这个按钮显示在表格上方。此按钮应位于此表下方。我该如何解决这个问题?
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.MyList.FirstOrDefault().Name)
</th>
<th>
@Html.DisplayNameFor(model => model.MyList.FirstOrDefault().Amount)
</th>
</tr>
@using (Html.BeginForm())
{
@Html.ValidationSummary("", new { @class = "text-danger" })
<br />
for (var i = 0; i < Model.MyList.Count; i++)
{
<tr>
<td>
@Html.DisplayFor(model => model.MyList[i].Name)
@Html.HiddenFor(model => model.MyList[i].Name)
</td>
<td>
@Html.TextBoxFor(model => model.MyList[i].Amount)
@Html.HiddenFor(model => model.MyList[i].Amount)
</td>
</tr>
}
<input type="submit" value="Confirm" class="btn btn-success" />
}
</table>
最佳答案
试试这个。您正在将表格代码与其余的 Html 混合
@using (Html.BeginForm())
{
@Html.ValidationSummary("", new { @class = "text-danger" })
<br />
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.MyList.FirstOrDefault().Name)
</th>
<th>
@Html.DisplayNameFor(model => model.MyList.FirstOrDefault().Amount)
</th>
</tr>
@for (var i = 0; i < Model.MyList.Count; i++)
{
<tr>
<td>
@Html.DisplayFor(model => model.MyList[i].Name)
@Html.HiddenFor(model => model.MyList[i].Name)
</td>
<td>
@Html.TextBoxFor(model => model.MyList[i].Amount)
@Html.HiddenFor(model => model.MyList[i].Amount)
</td>
</tr>
}
</table>
<input type="submit" value="Confirm" class="btn btn-success" />
}
关于c# - 为什么此按钮在 ASP.NET MVC CSS 中显示在表格上方而不是下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36234230/