Davy Davy - 1 year ago 100
jQuery Question

Loading Partial View from JQuery not showing in MVC

I am having problem getting my partial view to render in ASP.Net MVC 1.0 when I load it with JQuery.

I have a controller like:

public ActionResult Index() {
return View(_invoiceService.FindAllInvoices());

public ActionResult InvoiceSearchResults() {
return PartialView("InvoiceSearchResults",_invoiceService.FindAllInvoices());

I have an Index View:

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%= Html.Script("/scripts/InvoiceSearch.js") %>

<div class="SearchBar">

<div class="SearchResults"></div>

<p><%= Html.ActionLink("Create New", "Create") %></p>

I then have a PartialView:


<% foreach (var item in Model) { %>
<%= Html.ActionLink("Edit", "Edit", new { id=item.InvoiceId }) %> |
<%= Html.ActionLink("Details", "Details", new { id=item.InvoiceId })%>
<td><%= Html.Encode(item.InvoiceId) %></td>
<td><%= Html.Encode(item.InvoiceNo) %></td>
<td><%= Html.Encode(item.SupplierId) %></td>
<td><%= Html.Encode(String.Format("{0:g}", item.InvoiceDate)) %></td>
<td><%= Html.Encode(String.Format("{0:F}", item.TotalValue)) %></td>
<td><%= Html.Encode(String.Format("{0:g}", item.InputDate)) %></td>
<td><%= Html.Encode(String.Format("{0:g}", item.PaymentDueDate)) %></td>
<td><%= Html.Encode(item.InvoiceStatusId) %></td>
<td><%= Html.Encode(item.AuthoriserId) %></td>
<% } %>

I have some JQuery:

$(document).ready(function() {
$("#InvoiceDropDown").change(function() {

I've removed some of the code that I know is working to make the question easier to read.

When I click on the my DropDownList it calls the JQuery, goes to my controller and seems to run the partial class but it doesn't render anything.

I've tried evilDonald's answer and the same thing happens so maybe something stupid I've done somewhere?

Any help or general advice here much appreciated.

Answer Source

should have been:


selector issues - couldn't see it for looking at it.

Thanks (EvilDonald - I've voted up your answer)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download