Exemplo n.º 1
0
 /// <summary>
 /// Returns an anchor element (a element) that contains the virtual path of the specified action.
 /// </summary>
 public static MvcHtmlString ActionLinkLang(this HtmlHelper htmlHelper, string linkText, string actionName,
                                            RouteValueDictionary routeValues)
 {
     if (routeValues == null)
     {
         routeValues = new RouteValueDictionary();
     }
     routeValues[MvcUrlExtension.LanguageRouteKey] = MvcUrlExtension.GetCultureTwoDigit();
     return(htmlHelper.ActionLink(linkText, actionName, null, routeValues, new RouteValueDictionary()));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Generates a fully qualified URL for an action method by using the specified action name, controller name, route values, protocol to use, and host name.
 /// </summary>
 public static string ActionLang(this UrlHelper helper, string actionName, string controllerName,
                                 RouteValueDictionary routeValues, string protocol, string hostName)
 {
     if (routeValues == null)
     {
         routeValues = new RouteValueDictionary();
     }
     routeValues[MvcUrlExtension.LanguageRouteKey] = MvcUrlExtension.GetCultureTwoDigit();
     return(UrlHelper.GenerateUrl(null, actionName, controllerName, protocol, hostName, null, routeValues,
                                  helper.RouteCollection, helper.RequestContext, true));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns an anchor element (a element) that contains the virtual path of the specified action.
 /// </summary>
 public static MvcHtmlString ActionLinkLang(this HtmlHelper htmlHelper, string linkText, string actionName)
 {
     return(htmlHelper.ActionLink(linkText, actionName, null,
                                  new RouteValueDictionary
     {
         {
             MvcUrlExtension.LanguageRouteKey,
             MvcUrlExtension.GetCultureTwoDigit()
         }
     },
                                  new RouteValueDictionary()));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use.
 /// </summary>
 public static string ActionLang(this UrlHelper helper, string actionName, string controllerName, object routeValues,
                                 string protocol)
 {
     return(UrlHelper.GenerateUrl(null, actionName, controllerName, protocol, null, null,
                                  new RouteValueDictionary(routeValues)
     {
         {
             MvcUrlExtension.LanguageRouteKey,
             MvcUrlExtension.GetCultureTwoDigit()
         }
     }, helper.RouteCollection,
                                  helper.RequestContext, true));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Returns an anchor element (a element) that contains the virtual path of the specified action.
 /// </summary>
 public static MvcHtmlString ActionLinkLang(this HtmlHelper htmlHelper, string linkText, string actionName,
                                            string controllerName, object routeValues, object htmlAttributes)
 {
     return(htmlHelper.ActionLink(linkText, actionName, controllerName,
                                  new RouteValueDictionary(routeValues)
     {
         {
             MvcUrlExtension.LanguageRouteKey,
             MvcUrlExtension.GetCultureTwoDigit()
         }
     },
                                  HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
 }
Exemplo n.º 6
0
 private static string GenerateUrlLang(
     UrlHelper helper,
     string routeName,
     string actionName,
     string controllerName,
     RouteValueDictionary routeValues)
 {
     if (routeValues == null)
     {
         routeValues = new RouteValueDictionary();
     }
     routeValues[MvcUrlExtension.LanguageRouteKey] = MvcUrlExtension.GetCultureTwoDigit();
     return(UrlHelper.GenerateUrl(routeName, actionName, controllerName, routeValues, helper.RouteCollection,
                                  helper.RequestContext, true));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Returns an anchor element (a element) that contains the virtual path of the specified action.
 /// </summary>
 public static MvcHtmlString ActionLinkLang(this HtmlHelper htmlHelper, string linkText, string actionName,
                                            string controllerName, string protocol, string hostName, string fragment,
                                            RouteValueDictionary routeValues,
                                            IDictionary <string, object> htmlAttributes)
 {
     if (string.IsNullOrEmpty(linkText))
     {
         throw new ArgumentException("linkText");
     }
     if (routeValues == null)
     {
         routeValues = new RouteValueDictionary();
     }
     routeValues[MvcUrlExtension.LanguageRouteKey] = MvcUrlExtension.GetCultureTwoDigit();
     return
         (MvcHtmlString.Create(HtmlHelper.GenerateLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection,
                                                       linkText, null, actionName, controllerName, protocol, hostName,
                                                       fragment, routeValues, htmlAttributes)));
 }