Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saied 349 posts 674 karma points
    Aug 31, 2015 @ 16:23
    Saied
    0

    Load cshtml with jquery.load

    I have a partial called BottomNavigation.cshtml in my Views/Partials folder. I am trying the following:

    $("#footer").load("../Views/Partials/BottomNavigation.cshtml");
    

    But it says 404 not found. Is this possible? Currently, I am doing:

    @{Html.RenderPartial("BottomNavigation.cshtml");} which does work.

  • Sean Håkansson 67 posts 193 karma points
    Aug 31, 2015 @ 19:00
    Sean HÃ¥kansson
    0

    Hi!

    Is it a static file or does it need a model to render?
    This should work for static content:

    public ActionResult GetPartial(string partialName){
        return PartialView("~/Views/Partials/"+partialName);
    }
    

    then

    $("#footer").load("../MyController/GetPartial?partialName=BottomNavigation");
    

    May I ask you what you are trying to achieve by loading it as ajax?

Please Sign in or register to post replies

Write your reply to:

Draft