我有一个页面,其中包含根据db中有多少人生成的多个文本框。对于每个人,将出现一个文本框,并在离开该文本框时存储给定值。在这种情况下,我得到第一个文本框的值后,值没有得到任何人都可以给任何jquery或剃刀功能。这里的文本框id是否相同我是否需要更改ID?给出一些代码示例
thanks
My razor syntax is look like
@{List<string> subGroups = new List<string>();}
@foreach (var account in Model.AnnualBudget.Accounts)
{
if (account.AccountName == "Others")
{ continue; }
if (!subGroups.Exists(sg => sg.Contains(account.AccountHead.AccountHeadName)))
{
<tr style="margin: 0; padding: 0;height:20px;">
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: left; width: 22%; padding-top: 0px; padding-bottom: 0px; padding-left: 10px; font-weight: 700;" colspan="6">@Html.DisplayFor(i => account.AccountHead.AccountHeadName)</td>
</tr>
if (!string.IsNullOrEmpty(account.AccountHead.AccountHeadName))
{
subGroups.Add(account.AccountHead.AccountHeadName);
}
}
<tr style="margin: 0; padding: 0; border-collapse: collapse;height:inherit;">
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: left; width: 23%; height: 100%; padding: 0;">@Html.HiddenFor(i => account.AccountID, new { style = "margin-top:5px;margin-bottom:5px;" })</td>
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: left; width: 23%; height: 100%; text-align: right; padding: 0;">@Html.DisplayFor(i => account.AccountName, new { style = "margin-top:10px;margin-bottom:5px;" })</td>
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: right; width: 15%; height: 100%; padding: 0;" id="account_AccountID">@Html.TextBoxFor(i => account.Planned, new { style = "width:95%;text-align:right;height:21px; margin-top:5px;margin-bottom:5px;margin-left:3px;margin-right:0px;" })</td>
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: right; width: 15%; height: 100%; padding: 0;">@Html.Raw(string.Format("{0:c}", account.AccountValue, new { style = "margin-top:15px;margin-bottom:5px;" }))</td>
<td style="border: thin; border-right-style: solid; border-bottom-style: solid; text-align: right; width: 14%; height: 100%; padding: 0;">@Html.Raw(string.Format("{0:c}", account.Deviation))</td>
</tr>
}
</table>
this razor usihg for each loop so for each data it taking same id for the controlers how can i modify them
答案 0 :(得分:1)
要向剃刀添加属性,请按照
添加它们@Html.TextBoxFor (x => x.FieldName, new { @class = "FieldClass" })
如果您有任何问题,请告诉我