2011-10-07 53 views
2

我需要从集合中创建超链接(ActionLink)的列表。在以下代码中应用htmlAttribute后,ActionLink不会触发回服务器。Ajax.ActionLink()在放置htmlAttributes后不会触发

@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 } 

    } 

回答

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 }) 

} 
+0

foreach循环就完成了。没有编译错误。虽然粘贴代码,我错过了最后一个括号令牌...... :( – StartingFromScratch

+0

确定你能查看页面源代码并让我知道为链接生成了什么html吗? – WooHoo

+0

感谢您的追踪!但是,我选择了jQuery的路径的@ Ajax.ActionLink和有东西在运行。[链接](http://stackoverflow.com/questions/7686542/jquery-need-to-show-modal-dialog-on-any-anchor-link-click-on-该页面)的另一个职位。 – StartingFromScratch