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 123 posts 608 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 172 posts 846 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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies