ASP.NET MVC Passing models by ActionLink

后端 未结 4 748
广开言路
广开言路 2020-12-14 07:53

I would like to pass a model and an int to a controller upon clicking an ActionLink.

@Html.ActionLink(\"Next\", \"Lookup\", \"User\         


        
4条回答
  •  生来不讨喜
    2020-12-14 08:21

    Please try this solution:

    @{
    var routeValueDictionary = new RouteValueDictionary("");
    routeValueDictionary.Add("Forenames",Forenames);
    routeValueDictionary.Add("Surname",Surname);
    routeValueDictionary.Add("DoB ",DoB );
    routeValueDictionary.Add("Postcode",Postcode );
    routeValueDictionary.Add("Page",PageNum );
    // Add any item you want!
    }
    @html.ActionLink("LinkName", "ActionName", "ControllerName",
    routeValueDictionary , new{@class="form-control"})
    

提交回复
热议问题