/// <summary> /// Generates a fully qualified URL for an action method by using the specified action name, controller name, route values and protocol to use. /// </summary> /// <param name="actionName">The name of the action.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="routeValues">Dictionary that contains the parameters for a route.</param> /// <param name="protocol">The protocol for the URL, such as "http" or "https".</param> /// <returns>The fully qualified URL to an action method..</returns> /// <exception cref="ArgumentNullException"></exception> public IEncodedString Action(string actionName, string controllerName, object routeValues, string protocol) { var routerValuesDict = UtilHelper.ObjectToDictionary(routeValues); return(Action(actionName, controllerName, routerValuesDict, protocol, null)); }
/// <summary> /// Returns an anchor element (a element) for the specified link text, action, controller, protocol, host name, route values, and HTML attributes. /// </summary> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="protocol">The protocol for the URL, such as "http" or "https".</param> /// <param name="hostName">The host name for the URL.</param> /// <param name="routeValues">An Object that contains the parameters for a route.</param> /// <param name="htmlAttributes">An Object that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="ArgumentNullException"></exception> public IEncodedString ActionLink(string linkText, string actionName, string controllerName, string protocol, string hostName, object routeValues, object htmlAttributes) { var routerValuesDict = UtilHelper.ObjectToDictionary(routeValues); var htmlAttributesDict = UtilHelper.ObjectToDictionary(htmlAttributes); return(ActionLink(linkText, actionName, controllerName, protocol, hostName, routerValuesDict, htmlAttributesDict)); }
public IEncodedString LabelFor <TValue>(Expression <Func <TModel, TValue> > expression, object htmlAttributes = null, string labelText = null) { var resolvedLabelText = labelText ?? UtilHelper.GetPropertyDisplayName(expression); var propName = UtilHelper.GetPropertyName(expression); var htmlAttributesStr = string.Empty; if (String.IsNullOrEmpty(resolvedLabelText)) { return(new HtmlEncodedString(string.Empty)); } if (htmlAttributes != null) { var htmlAttributesDict = UtilHelper.ObjectToDictionary(htmlAttributes); htmlAttributesStr = UtilHelper.ConvertDictionaryToString(htmlAttributesDict); } var tag = string.Format("<label {2}for=\"{0}\">{1}</label>", propName, HttpUtility.HtmlEncode(resolvedLabelText), htmlAttributesStr); return(new RawString(tag)); }
/// <summary> /// Returns an anchor element (a element) for the specified link text, action, controller, and route values. /// </summary> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="routeValues">An Object that contains the parameters for a route.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="ArgumentNullException"></exception> public IEncodedString ActionLink(string linkText, string actionName, string controllerName, object routeValues) { var routerValuesDict = UtilHelper.ObjectToDictionary(routeValues); return(ActionLink(linkText, actionName, controllerName, routerValuesDict, null)); }