Copied to clipboard

Flag this post as spam?

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


  • Roger Withnell 128 posts 613 karma points
    Jun 19, 2015 @ 16:00
    Roger Withnell
    0

    Pass a parameter to a controller

    I'm calling a SurfaceController from a PartialMacro and want to pass a parameter to the controller. Something like:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
        int FolderId = 1096;
        Html.Action("Index", "DocumentListSurface", FolderId);  
    }
    

    Picked up in the Controller with:

       public ActionResult Index(int FolderId)
    

    The Html.Action in the PartialMacro gets an error.

    What am I doing wrong?

    Your help would be much appreciated.

    Thanking you in anticipation.

    Roger

  • Jamie Pollock 174 posts 853 karma points c-trib
    Jun 19, 2015 @ 16:29
    Jamie Pollock
    102

    Hi Roger,
    Wouldn't you need to wrap the route values (FolderId) in a typeless object?

    example:

    Html.Action("Index", "DocumentListSurface", new { FolderId });  
    

    There shouldn't be any need to do

    Html.Action("Index", "DocumentListSurface", new { FolderId = FolderId });  
    

    As the local parameter name matches the route parameter name already. I hope that helps.

    Thanks,
    Jamie

Please Sign in or register to post replies

Write your reply to:

Draft