Is there a way to return a partial view from a Razor Pages PageModel handler?
An example might be some client side Ajax responding to an "Add Row" button click that returns a partial view when, say, adding a new table row to some editing grid we might have on a page.
When using controllers we would just do something like:
public IActionResult AddRow() => PartialView("_EditingRow");
See the comment here: https://github.com/aspnet/Mvc/issues/6664#issuecomment-322840073
cc @rynowak @DamianEdwards FYI
Yes, saw that.
I have created a page that does nothing else except return the partial as a work around for now setting Layout = null.
It would be great if in the future the page handler could return a partial view, or alternatively #6182 (ViewComponentPages) in the future might help?
@rmmcgr sounds like a dup of https://github.com/aspnet/Mvc/issues/6664. I listed a possible solution for it here: https://github.com/aspnet/Mvc/issues/6664#issuecomment-322840073
Oops, Had the page opened and didn't see the updated comments.
yeah i wanted this scenario to work.. my idea is i have a couple of Partials that i get via ajax and load them on Modal window, i populate them using something like this ..
<a id="createRoleModal" data-toggle="modal" asp-page-handler="AddEditApplicationRole" data-target="#modal-action-application-role" class="btn btn-primary">
And this is hitting ok my Handler, but i wanted to return the PartialView with a model from the server return PartialView("_AddEditApplicationRole", model);
This is super critical when ajax is involved and nowadays most if not all sites have lots of ajax.
It will be very useful to be able to do something like(we are talking about razor pages here):
public async Task<IActionResult> OnPostCreateAsync(Something something)
{
//some logic
return await PartialAsync(partialViewName, model, viewData);
}
and of course to include the same partial view from the cshtml page : @await Html.PartialAsync(...)
Hello experts,I want to implement load more button for my website ,https://mrnams.com
Can any one please give idea how to implement load more button to load more videos without refreshing (I mean without loosing loaded videos) page.
Similar to youtube functionality.
I am using .net core 2.1 version
Most helpful comment
This is super critical when ajax is involved and nowadays most if not all sites have lots of ajax.
It will be very useful to be able to do something like(we are talking about razor pages here):
and of course to include the same partial view from the cshtml page :
@await Html.PartialAsync(...)