1

我有一个页面,其中包含根据数据库中有多少人生成的多个文本框。每个人都会出现一个文本框,离开该文本框时将存储给定的值。在这种情况下,我得到了第一个文本框的值,之后没有得到的值任何人都可以提供任何 jquery 或 razor 函数。这里的文本框 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
4

1 回答 1

1

要将属性添加到剃须刀,您可以像这样添加它们

@Html.TextBoxFor (x => x.FieldName, new { @class = "FieldClass" })

如果您有任何问题,请告诉我

于 2013-11-18T05:44:45.327 回答