/// <summary> /// Begins a new action link. For use in a using statement, allowing other code inside the tag. /// </summary> /// <returns></returns> public static MvcTag BeginActionLink(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, object htmlAttributes) { string hrefUrl = UrlHelper.GenerateUrl(null, actionName, controllerName, htmlHelper.AnonymousObjectToHtmlAttributesMvc2(routeValues), htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, true); //This uses MVC2 helper below instead of MVC3 HtmlHelper.AnonymousObjectToHtmlAttributes because it is not as defensive... RouteValueDictionary attrs = htmlHelper.AnonymousObjectToHtmlAttributesMvc2(htmlAttributes); attrs.Add("href", hrefUrl); return BeginTag(htmlHelper, "a", attrs); }
/// <summary> /// Begins a new tag of any kind. For use in a using statement, allowing other code inside the tag. /// </summary> /// <param name="htmlHelper"></param> /// <param name="tagName"></param> /// <param name="htmlAttributes"></param> /// <returns></returns> public static MvcTag BeginTag(this HtmlHelper htmlHelper, string tagName, object htmlAttributes) { return htmlHelper.BeginTag(tagName, htmlHelper.AnonymousObjectToHtmlAttributesMvc2(htmlAttributes)); //This uses MVC2 helper below instead of MVC3 HtmlHelper.AnonymousObjectToHtmlAttributes because it is not as defensive... }