00001 using System.Web.Mvc; 00002 using System.Web.Mvc.Html; 00003 using System.Web.Routing; 00004 00005 namespace N2.Web.Mvc.Html 00006 { 00007 public static class LinkExtensions 00008 { 00009 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item) 00010 { 00011 return ActionLink(htmlHelper, item, "Index"); 00012 } 00013 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item, string action) 00014 { 00015 if (item == null) return null; 00016 00017 return htmlHelper.ActionLink(item.Title, action, null, new RouteValueDictionary() { { "item", item } }, new RouteValueDictionary()); 00018 } 00019 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item, object routeValues) 00020 { 00021 return ActionLink(htmlHelper, item, "Index", routeValues); 00022 } 00023 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item, string action, object routeValues) 00024 { 00025 if (item == null) return null; 00026 00027 return htmlHelper.ActionLink(item.Title, action, null, new RouteValueDictionary(routeValues) { { "item", item } }, new RouteValueDictionary()); 00028 } 00029 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item, object routeValues, object htmlAttributes) 00030 { 00031 return ActionLink(htmlHelper, item, "Index", routeValues, htmlAttributes); 00032 } 00033 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, ContentItem item, string action, object routeValues, object htmlAttributes) 00034 { 00035 if (item == null) return null; 00036 00037 return htmlHelper.ActionLink(item.Title, action, null, new RouteValueDictionary(routeValues) { { "item", item } }, new RouteValueDictionary(htmlAttributes)); 00038 } 00039 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ContentItem item, object routeValues, object htmlAttributes) 00040 { 00041 return htmlHelper.ActionLink(linkText, "Index", null, new RouteValueDictionary(routeValues) { { "item", item } }, new RouteValueDictionary(htmlAttributes)); 00042 } 00043 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ContentItem item, string action, object routeValues, object htmlAttributes) 00044 { 00045 return htmlHelper.ActionLink(linkText, action, null, new RouteValueDictionary(routeValues) { { "item", item } }, new RouteValueDictionary(htmlAttributes)); 00046 } 00047 } 00048 }