Ajax - returning partial view only (problem)

Topics: Customizing Orchard, General
Apr 8, 2013 at 8:56 PM

I am trying to refresh my list of items with using AJAX but all I get is the partial view. I need the partial view to be displayed in the layout from where it is called.

This is my view:
@using Orchard.UI.Resources
@model Ignite.Events.ViewModels.EventListPartViewModel

@Ajax.ActionLink("Prev Month", "GetEventListItems", "Events", new { area = "Ignite.Events", __RequestVerificationToken = Html.AntiForgeryToken() }, new AjaxOptions{ HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "event-list"})

<table id="event-list" class="event-list">
    @Html.Partial("_EventList", Model.Events)

<div id="calendar" class="clear"></div>
and this is my controller action:
        public ActionResult GetEventListItems(int? month, int? year)
            if (month == null || year == null)
                month = DateTime.Now.Month;
                year = DateTime.Now.Year;

            var result = _eventListDataService.GetEventListItems((int) month, (int) year);

            return PartialView("_EventList", result);
This is the top of the controller:
using System;
using System.Linq;
using System.Web.Mvc;
using Ignite.Events.Services;
using Orchard;
using Orchard.ContentManagement;
using Orchard.Themes;
using System.Net;
using Orchard.Core.Title.Models;
using Orchard.Utility.Extensions;
using Orchard.Fields.Fields;
using Orchard.Core.Common.Fields;

namespace Ignite.Events.Controllers
    public class EventsController : Controller
Could you please tell me what I am doing wrong that only my partial view is returned and displayed?

Thank you,

Apr 8, 2013 at 11:13 PM
You get the partial view since that's what you're returning: a PartialViewResult.
If you want a view result that includes the entire layout, you should decorate your action or controller with the ThemedAttribute(true).
Apr 8, 2013 at 11:40 PM
Even with ThemedAttribute(true) still returns just the parital view.
Apr 9, 2013 at 1:12 AM
Even when you return a ViewResult, not a PartialViewResult?