Asp.net mvc MVC:从复杂数据类型中提取RouteValue
我希望将RouteValue作为复杂数据类型传递到HtmlHelper中,而不是使用匿名类型 例如 而不是Asp.net mvc MVC:从复杂数据类型中提取RouteValue,asp.net-mvc,html-helper,Asp.net Mvc,Html Helper,我希望将RouteValue作为复杂数据类型传递到HtmlHelper中,而不是使用匿名类型 例如 而不是 @Html.Navigator("Title", new {startDate=Model.StartDate, filter=Model.Filter, ...and so on}) 对于后者,我使用: public static MvcHtmlString Navigator(this HtmlHelper html, string title, object routeValues
@Html.Navigator("Title", new {startDate=Model.StartDate, filter=Model.Filter, ...and so on})
对于后者,我使用:
public static MvcHtmlString Navigator(this HtmlHelper html, string title, object routeValues)
anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
添加RouteValue
无法确定如何为SearchCriteria执行此操作。
有什么建议、建议吗
注意,Guy您可以基于对象创建新的RouteValuesDictionary。假设
Model.SearchCriteria
是SearchCriteria
public static MvcHtmlString Navigator(this HtmlHelper html, string title, SearchCriteria searchCriteria)
{
RouteValuesDictionary routeValues = new RouteValuesDictionary(searchCriteria);
public static MvcHtmlString Navigator(this HtmlHelper html, string title, SearchCriteria searchCriteria)
{
RouteValuesDictionary routeValues = new RouteValuesDictionary(searchCriteria);