Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to load a partial view with Ajax.ActionLink
    primarykey
    data
    text
    <p>After reading a few other posts on here I've got this far with attempting to load a partial view on the click of a link (the text link may actually change to be an image once I get past this proof of concept stage). The problem is I am being directed to the partial view on click instead of it populating a div within the view I am clicking the link on:</p> <p>The layout:</p> <pre><code>&lt;script src="@Url.Content("~/scripts/jquery-1.5.1.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>The View:</p> <pre><code> @Ajax.ActionLink("Item 1 Ajax", "Details", "Portfolio", new { name = "test" }, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "row1Content", OnComplete = "portfolioItemLoaded" }) &lt;div id="row1content"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; function portfolioItemLoaded() { alert("Done"); } &lt;/script&gt; </code></pre> <p>The controller:</p> <pre><code>public class PortfolioController : Controller { public ActionResult Details(string name) { return PartialView(name); } } </code></pre> <p>The partial (obviously named test.cshtml):</p> <pre><code>&lt;p&gt;Item 1 test&lt;/p&gt; </code></pre> <p>Have I missed something obvious? It's the first time I have attempted to use AJAX in MVC, so there might be a school boy error or two.</p> <p>I am planning on having several different Ajax Action Links that call different partial views, hence the reason I am passing the name in to the controller.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload