Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
HI, there; I am having an ajax call when clicking a button in my Index view to return a partial view.
When the action method runs my view model (inhertis from RenderModel):
public RoomDetailViewModel() : base(Umbraco.Web.UmbracoContext.Current.PublishedContentRequest.PublishedContent) { ..... }
it shows "PublishedContentRequest" is null.
Does someone have similar issue and have a solution to this?
thx.
Cheers Robert
Hi Robert,
Are you using RenderMvcController with AJAX? Can you share your code?
It's not the best way to perform AJAX requests, UmbracoApiController is specially for that case.
Thanks,
Alex
HI, Alex; NO, I am using SurfaceController with ajax. View:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<IHaveSiteViewModel> @{ Layout = "_Layout.cshtml"; } @using (Html.BeginForm()) { <div id="mySiteList"> @Html.Partial("MySiteList", Model) </div> }
Partial View:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<IHaveSiteViewModel> @foreach (var site in Model.MySitesList) { <div class="media-object stack-for-small"> <div class="media-object-section"> <a href="@Url.SurfaceAction("EditRoomDetail", "RoomSurface", new { siteID = site.SiteID })"> <img class="thumbnail" src=""> </a> </div> </div> } <button type="button" class="button" id="addNew">Add New</button>
ajax call:
$("#addNew").click(function () { $.ajax({ url: '/umbraco/surface/RoomSurface/IHaveSite', type: 'post', datatype: 'json', processData: false, success: function (resultData) { if (resultData != null) { $("#mySite").html(resultData); } } }) })
Action Method:
public ActionResult IHaveSite() { ..... IHaveSiteViewModel mySite = null; mySite = new IHaveSiteViewModel();} } Where: In IHaveSiteViewModel: public IHaveSiteViewModel() : base(Umbraco.Web.UmbracoContext.Current.PublishedContentRequest.PublishedContent) { }
Cheers Robert.
Hi Robert, I'm having the exact same issue. Have you found a solution by any chance?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
"PublishedContentRequest" is null
HI, there; I am having an ajax call when clicking a button in my Index view to return a partial view.
When the action method runs my view model (inhertis from RenderModel):
it shows "PublishedContentRequest" is null.
Does someone have similar issue and have a solution to this?
thx.
Cheers Robert
Hi Robert,
Are you using RenderMvcController with AJAX? Can you share your code?
It's not the best way to perform AJAX requests, UmbracoApiController is specially for that case.
Thanks,
Alex
HI, Alex; NO, I am using SurfaceController with ajax. View:
Partial View:
ajax call:
Action Method:
Cheers Robert.
Hi Robert, I'm having the exact same issue. Have you found a solution by any chance?
is working on a reply...