简体   繁体   中英

Html.RenderAction not using my routeValue parameters

I'm calling a RenderAction but my PartialViewResult is not receiving my sent parameter.

Here's my Default Route:

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

Here's my Call:

@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { level = Model.InvestmentGroup });}

Here's my Action:

 public PartialViewResult InvestmentGroupDropDown(Guid? selectedId)
        {
        }

I reach my Action no problem but the value I'm trying to send from my Model. Is not there when I reach my Action. I can see the value in debug mode plain as day in the RenderActions parameter. Why does it seem to be ignoring my parameter?

I should be getting a Guid in my PartialViewResult, instead i'm getting null.

Tieson T. provided me with an answer! Thank you!

I didn't realise the object name mattered here but it does. I changed level to the parameter name of my Action 'selectedId' and voila we have cookies!

@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { **level** = Model.InvestmentGroup });}
@{ Html.RenderAction("InvestmentGroupDropDown", "TPAs", new { **selectedId** = Model.InvestmentGroup });}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM