【问题标题】:MVC - button to fire an Ajax.ActionLinkMVC - 触发 Ajax.ActionLink 的按钮
【发布时间】:2011-07-19 18:26:25
【问题描述】:
@Ajax.ActionLink(
    "Link Text", 
    "RefreshTestStatus2", 
    "refresh",
    new AjaxOptions { 
        UpdateTargetId = "status", 
        InsertionMode = InsertionMode.InsertBefore })

但我想使用看起来像提交按钮的东西来触发它。有谁知道怎么做?

朱迪

【问题讨论】:

    标签: asp.net-mvc ajax


    【解决方案1】:

    我决定将它实现为 Ajax 表单。

    @using(Ajax.BeginForm( 
      "RefreshTestStatus2", 
      "refresh",
      new AjaxOptions { 
        UpdateTargetId = "status", 
        InsertionMode = InsertionMode.InsertBefore }))
    {
      <input type="submit" name="submit" value="Link Text" />
    }
    

    我认为可以肯定地说它不像 Ajax.ActionLink 那样干净,但会给你一个输入按钮。

    【讨论】:

    • +1,直接回答问题!提交按钮用于提交表单,因此是 Ajax 表单!
    【解决方案2】:

    一种选择是使用一些 css 使链接看起来像一个按钮

    比如这个example

    另见相关question here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多