C# 是否可以在ASP.NET MVC中分配HTML按钮ID?
我使用for循环填充表:C# 是否可以在ASP.NET MVC中分配HTML按钮ID?,c#,asp.net-mvc,html,razor,C#,Asp.net Mvc,Html,Razor,我使用for循环填充表: @using (Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" })) { <table id="table1" border="1" style ="width:100%"> @for (int i = 1; i < 13; i++) { <tr> <td>
@using (Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" })) {
<table id="table1" border="1" style ="width:100%">
@for (int i = 1; i < 13; i++)
{
<tr>
<td>
@(i.ToString()+". Details")
</td>
<td>
<button type="button" onclick="invisiblize(i)">Show detail @i</button>
</td>
</tr>
}
</table>
@使用(Html.BeginForm(null,null,FormMethod.Get,new{name=“frm”,id=“frm”})){
@对于(int i=1;i<13;i++)
{
@(i.ToString()+“.Details”)
显示细节@i
}
是否可以为上述代码后生成的按钮分配ID?我不确定您是否需要在代码运行后分配ID,但这将允许您在代码运行时设置ID
@using (Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" })) {
<table id="table1" border="1" style ="width:100%">
@for (int i = 1; i < 13; i++)
{
<tr>
<td>
@(i.ToString()+". Details")
</td>
<td>
<button id="div@i.ToString()" type="button" onclick="invisiblize(i)">Show detail @i</button>
</td>
</tr>
}
</table>
@使用(Html.BeginForm(null,null,FormMethod.Get,new{name=“frm”,id=“frm”})){
@对于(int i=1;i<13;i++)
{
@(i.ToString()+“.Details”)
显示细节@i
}
我不确定您是否需要在代码运行后分配ID,但这将允许您在代码运行时设置ID
@using (Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" })) {
<table id="table1" border="1" style ="width:100%">
@for (int i = 1; i < 13; i++)
{
<tr>
<td>
@(i.ToString()+". Details")
</td>
<td>
<button id="div@i.ToString()" type="button" onclick="invisiblize(i)">Show detail @i</button>
</td>
</tr>
}
</table>
@使用(Html.BeginForm(null,null,FormMethod.Get,new{name=“frm”,id=“frm”})){
@对于(int i=1;i<13;i++)
{
@(i.ToString()+“.Details”)
显示细节@i
}