Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ajax.actionlink replace vs replacewith

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.

I can't find a comparison anywhere on google

like image 250
duxfox-- Avatar asked Oct 27 '14 12:10

duxfox--


1 Answers

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>

Response from ajax

<span>This is the result</span>

with Replace option targeting myResults

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

using ReplaceWith option targeting myResults

<body>
    <span>This is the result</span>
</body>
like image 111
DLeh Avatar answered Oct 19 '22 01:10

DLeh