我需要从集合中构建超链接列表(ActionLink)。在以下代码中应用htmlAttribute后,ActionLink不会触发回服务器。
@foreach (MillitarySlot slot in item.MondaySlots)
{
@Ajax.ActionLink(linkText: @slot.SlotText,
actionName: "CreateIndex",
routeValues: new { someId = slot.Id },
ajaxOptions: new AjaxOptions
{
UpdateTargetId = "divCreateSchedule",
InsertionMode = InsertionMode.Replace,
HttpMethod = "post"
},
//After adding following htmlAttribule, view does not trigger call
htmlAttributes: new { title = slot.ToolTip, style = "color:" + slot.Color }
}
答案 0 :(得分:2)
尝试在slot.Color}之后添加一个括号,例如..
@foreach (MillitarySlot slot in item.MondaySlots)
{
@Ajax.ActionLink(linkText: @slot.SlotText,
actionName: "CreateIndex",
routeValues: new { someId = slot.Id },
ajaxOptions: new AjaxOptions
{
UpdateTargetId = "divCreateSchedule",
InsertionMode = InsertionMode.Replace,
HttpMethod = "post"
},
//After adding following htmlAttribule, view does not trigger call
htmlAttributes: new { title = slot.ToolTip, style = "color:" + slot.Color })
}