下面是一个有效的编辑器模板,但需要改进。具体来说,该复选框有一个 onclick 事件,并调用了一个 javascript 函数;
AdministratorFlagClickFunc(employeeId)
我应该做的是在脚本中指定一个 click() 事件。但是,鉴于模板是网格的一部分,并且我需要识别每一行上复选框的 id 以及相关参数,我该怎么做?
@model UserLineViewModel
<tr>
<td>
@Html.DisplayFor(x => x.Employee.Forename)
</td>
<td>
@Html.DisplayFor(x => x.Employee.Surname)
</td>
<td>
@Html.DisplayFor(x => x.UserScd.Created)
</td>
<td style="text-align: center;">
@Html.CheckBoxFor(x => x.UserScd.AdminFlag,
new { id = "checkBoxAdministratorFlag",
onclick = "AdministratorFlagClickFunc(" + Model.UserScd.EmployeeId + ")" })
</td>
<td>
@Ajax.ActionLink("Remove", "Delete", new { id=Model.UserScd.EmployeeId }, new AjaxOptions()
{
OnSuccess="refreshPostback"
, Confirm="Are you sure that you want to remove this person?"
, HttpMethod = "post"
})
</td>
</tr>