添加 htmlAttributes 后 Ajax.ActionLink() 不会触发

发布于 2024-12-08 10:04:07 字数 651 浏览 0 评论 0原文

我需要从集合中构建超链接(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 }

    }

I need to build list of hyperlink(ActionLink) from the collection. After applying htmlAttribute in following code, ActionLink does not trigger back to server.

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

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-12-15 10:04:07

例如,尝试在 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 })

}

Try adding a bracket after slot.Color } for example..

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

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文