Example #1
0
 public static MvcHtmlString ActionLinkFor <TController>(this HtmlHelper helper, string text, Expression <Func <TController, ActionResult> > actionDef,
                                                         object routeValues,
                                                         IDictionary <string, object> htmlAttributes)
     where TController : IController
 {
     return(helper.ActionLinkFor(text, actionDef, new RouteValueDictionary(routeValues), htmlAttributes));
 }
Example #2
0
        public static MvcHtmlString ActionLinkFor <TController>(this HtmlHelper helper, Expression <Func <TController, ActionResult> > actionDef, IDictionary <string, object> htmlAttributes, bool generateRouteValues = true)
            where TController : IController
        {
            var method  = StaticReflection.GetMember(actionDef) as ICallableMember;
            var display = method.GetCustomAttribute <DisplayAttribute>();
            var text    = display != null?display.GetName() ?? method.Name : method.Name;

            var methodExp = actionDef.Body as MethodCallExpression;
            IDictionary <string, object> routeVals = null;

            if (generateRouteValues)
            {
                routeVals = GetRouteValuesFromMethodCall(methodExp);
            }
            return(helper.ActionLinkFor(text, actionDef, new RouteValueDictionary(routeVals), htmlAttributes));
        }
Example #3
0
 public static MvcHtmlString ActionLinkFor <TController>(this HtmlHelper helper, string text, Expression <Func <TController, ActionResult> > actionDef,
                                                         object routeValues)
     where TController : IController
 {
     return(helper.ActionLinkFor(text, actionDef, routeValues, null));
 }
Example #4
0
 public static MvcHtmlString ActionLinkFor <TController>(this HtmlHelper html, Expression <Func <TController, Task <ActionResult> > > expr, string linkText)
     where TController : IController
 {
     return(html.ActionLinkFor <TController, ActionResult>(expr, linkText));
 }