ajax.actionlink替换vs替换 [英] ajax.actionlink replace vs replacewith

查看:101
本文介绍了ajax.actionlink替换vs替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET-MVC应用程序中使用的视图中正在使用Ajax.ActionLink,并且正在使用InsertionMode.Replace,但是我看到还有一个ReplaceWith选项.两者有什么区别?一个替代品是否比另一个替代品更多/更少.我需要将要替换的div完全替换为局部视图.

I'm using Ajax.ActionLink in a view that I have on an ASP.NET-MVC application and I'm using InsertionMode.Replace, but I see there's also a ReplaceWith option. What's the difference between the two? Does one replace something more/less than the other one. I need the div I'm replacing to be completely replaced with the partial view.

我在Google的任何地方都找不到比较

I can't find a comparison anywhere on google

推荐答案

Replace将内容替换为新内容. ReplaceWith将替换整个元素.

Replace will replace the content with the new content. ReplaceWith will replace the entire element.

<body>
    <div id="myResults">
        <p> Results will be displayed here </p>
    </div>
</body>

ajax的响应

<span>This is the result</span>

具有Replace选项且定位myResults

<body>
    <div id="myResults">
        <span>This is the result</span>
    </div>
</body>

使用ReplaceWith选项定位myResults

<body>
    <span>This is the result</span>
</body>

这篇关于ajax.actionlink替换vs替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆