![]() ![]() If (anonymousObject = null) return dictionary įoreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(anonymousObject))ĭictionary.Add(propertyDescriptor.Name, propertyDescriptor.GetValue(anonymousObject)) Private static Dictionary AnonymousObjectToKeyValue(object anonymousObject) Var attributes = AnonymousObjectToKeyValue(htmlAttributes) Public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, Expression> expression, string linkText, object routeValues, object htmlAttributes) where TController : Controller ![]() Link.MergeAttribute("href", urlHelper.Action(actionName, controllerName, routeValues)) Public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, Expression> expression, string linkText, object routeValues) ![]() Return new MvcHtmlString(link.ToString()) Link.MergeAttribute("href", urlHelper.Action(actionName, controllerName)) String controllerName = typeof(TController).Name.Replace("Controller", "") String actionName = ExpressionHelper.GetExpressionText(expression) Var urlHelper = new UrlHelper(, htmlHelper.RouteCollection) Public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, Expression> expression, string linkText) You will need to put this in the namespace: public static class MyProjectExtensions If you want to go all fancy-pants, here's how you can extend it to be able to do this: => x.Details(), article.Title, new )) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |