Copied to clipboard

Flag this post as spam?

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


  • Nadine Fisch 159 posts 429 karma points
    Oct 05, 2020 @ 08:41
    Nadine Fisch
    0

    PartialView doesnt render after calling SurfaceController

    Hi,

    I have a an issue with rendering my partial view. I get no errors, I dont see the content of my partial view.

    I call the Action in my template (example.cshtml)

    @{Html.Action("RenderExample", "ExampleSurface");}
    

    afterwards the Actions is called correctly (i logged it into a file)

        public ActionResult RenderExample(ExampleModel model)
        {
    
            try
            {
    
                return PartialView(PARTIAL_VIEW_FOLDER + "_Example.cshtml", model);
            }
            catch (Exception)
            {
    
                throw ;
            }
        }
    

    This is the partialview "_Example.cshtml"

    @inherits UmbracoViewPage<ExampleProject.App_Code.Models.ExampleModel >
    
    <div>Here should be the  html </div>
    
  • Nadine Fisch 159 posts 429 karma points
    Oct 05, 2020 @ 09:54
    Nadine Fisch
    100

    Finally, I found the solution. I need to call RenderAction instead of Action

    @{Html.RenderAction("RenderExample", "ExampleSurface");}
    
  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Oct 05, 2020 @ 09:54
    Marc Goodson
    0

    Hi Nadine

    I think you are 'writing out' the output of the surface controller inside a code block! so it never appears...

    try:

    @Html.Action("RenderExample", "ExampleSurface")
    

    instead

    regards

    Marc

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Oct 05, 2020 @ 09:55
    Marc Goodson
    1

    ha Nadine

    I was too late! my a microsecond...

    but yes calling RenderAction inside the code block is the other option...

    regards

    Marc

  • Nadine Fisch 159 posts 429 karma points
    Oct 05, 2020 @ 09:56
    Nadine Fisch
    0

    :) Really funny! Thanks anyway for your advice, Marc :)

Please Sign in or register to post replies

Write your reply to:

Draft