Terry

Terry

  • NA
  • 148
  • 0

Pass multiple values thru RouteValueDictionary in ActionLink

Jul 30 2017 9:34 PM
Hello,
 
   I have buttons where I want to pass Model and other parameters to the Action method of the Controller. Using RouteValueDictionary, it allows me to send only 1 Key-Value pair. How do I add more than 1 Key-Value pair ?
 
View Code :
  1.                   
  2.                 @* Using RouteValueDictionary  
  3. new RouteValueDictionary(Model) -- shows result just of page 1, as page value not passed & default is 1  
  4. new RouteValueDictionary ({ mivm = Model, page = Model.CurrentPage + 1})  ---  Model is null in Controller Index Action method  
  5.   
  6. button type="button" id="btnNext" class="btn btn-sm" title="Next" onclick="location.href='@Url.Action("Index", "Member", new RouteValueDictionary(new { mivm = Model, page = Model.CurrentPage + 1 })) )'" @( (Model.CurrentPage == Model.TotalPages) ? "disabled" : "")><span class="glyphicon glyphicon-step-forward"></span></button>  
  7.                 *@  
Controller Action Method :
  1. public ActionResult Index(MemberIndexViewModel mivm, int page = 1, string sort = ""string sortdir = "asc")   {  
  2.  ........  
  3. }  
 Where am I going wrong and How to make this working ??
 
Any help is highly appreciated.
 
Thanks,
 
 
 

Answers (1)