【问题标题】:Updating a table's ActionLinks in MVC using JSON and JQuery使用 JSON 和 JQuery 在 MVC 中更新表 ActionLink
【发布时间】:2009-10-25 18:28:25
【问题描述】:

我有以下 HTML 来显示表格元素内的图像操作:

<%= Html.ActionLink("[EditImg]", "Edit", new { id = item.GrossBaseReconId }, new { id = "BaseReconEdit", rowsid = item.GrossBaseReconId }).Replace("[EditImg]", "<img src='/Content/images/page_white_edit.png' alt='Edit Details' title='Edit Details'>")%>  


<%= Ajax.ImageActionLink("/Content/images/delete.jpg", "Delete", "DeleteElement", new { id = item.GrossBaseReconId }, new AjaxOptions { OnSuccess = "DeleteGrossBasedRecon", Confirm = "Delete Gross Recon?", HttpMethod = "Delete" })%>

我使用 JQuery 和 JSON 添加和编辑,需要在 POST 上刷新或添加到我的表中。

我的问题是:当我编辑或插入一行时,我是否可以使用 JSON 将这些链接呈现到我的表格中?

我不确定如何正确构建字符串。

提前致谢

【问题讨论】:

    标签: jquery asp.net-mvc json


    【解决方案1】:

    您将使用返回的 PartialView 操作方法。 创建响应 tr/td。更新或删除 resnpose 表标签并替换它。 它是简单的实施解决方案。怎么样?

    【讨论】:

      【解决方案2】:

      看起来很明显 - 查看生成的源代码并按照呈现的方式构建字符串。

      var row = '<td>' + '<a href="/PaymentGross/Edit/' + data.GrossBaseReconId +'" id="BaseReconEdit" rowsid="' + data.GrossBaseReconId + '"><img src=' + "'" + '/Content/images/page_white_edit.png' + "'" + ' alt= ' + "'" + 'Edit Details' + '"' + ' title=' + "'" + 'Edit Details' + "'" + '></a>' + '&nbsp' + 
      

      '' + '' + 行的其余部分

      它不漂亮 - 欢迎任何更简单的方法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-05-25
        • 1970-01-01
        • 2023-03-03
        • 1970-01-01
        • 2012-08-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多