public void ReturnsCorrectly() { string attributeName = "AttributeName"; string attributeValue = "AttributeValue"; Action<HtmlAttributeBuilder> attributeExpression = new Action<HtmlAttributeBuilder>( x => x.Attribute( attributeName, attributeValue ) ); var result = attributeExpression.GetAttributes(); Assert.IsNotNull( result ); Assert.AreEqual( attributeValue, result[ attributeName ] ); }
/// <summary> /// Returns an anchor element that contains the virtual path for the specified route values; when the link is clicked, a request is made to the virtual path asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="routeName">The name of the route to use to obtain the form post URL.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element.</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString RouteLink( this AjaxHelper ajaxHelper, string linkText, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.RouteLink( linkText, routeName, routeValues, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response using the specified routing information. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="routeName">The name of the route to use to obtain the form post URL.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginRouteForm( this AjaxHelper ajaxHelper, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginRouteForm( routeName, routeValues, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified location. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <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="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.ActionLink( linkText, actionName, controllerName, null, attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified action. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="routeName">The name of the route that is used to return a virtual path.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString RouteLink( this HtmlHelper htmlHelper, string linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.RouteLink( linkText, routeName, protocol, hostName, fragment, routeValues, attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified action. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString RouteLink( this HtmlHelper htmlHelper, string linkText, object routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.RouteLink( linkText, new RouteValueDictionary( routeValues ), attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="method">The HTTP method for processing the form, either GET or POST.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginForm( this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginForm( actionName, controllerName, null, method, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="routeName">The name of the route to use to obtain the form-post URL.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="method">The HTTP method for processing the form, either GET or POST.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginRouteForm( this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, FormMethod method, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginRouteForm( routeName, routeValues, method, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</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> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginActionLink( actionName, controllerName, null, null, null, routeValues, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response that contains the virtual path for the specified route values; /// when the link is clicked, a request is made to the virtual path asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="routeName">The name of the route to use to obtain the form post URL.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginRouteLink( this AjaxHelper ajaxHelper, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginRouteLink( routeName, protocol, hostName, fragment, routeValues, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response that contains the virtual path for the specified route values; /// when the link is clicked, a request is made to the virtual path asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="routeName">The name of the route to use to obtain the form post URL.</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginRouteLink( this AjaxHelper ajaxHelper, string routeName, object routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginRouteLink( routeName, null, null, null, new RouteValueDictionary( routeValues ), ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response that contains the URL to the specified action method; /// when the action link is clicked, the action method is invoked asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="actionName">The name of the action method.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this AjaxHelper ajaxHelper, string actionName, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginActionLink( actionName, null, null, null, null, null, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response that contains the virtual path for the specified route values; /// when the link is clicked, a request is made to the virtual path asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginRouteLink( this AjaxHelper ajaxHelper, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginRouteLink( null, null, null, null, routeValues, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response that contains the URL to the specified action method; /// when the action link is clicked, the action method is invoked asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="actionName">The name of the action method.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this AjaxHelper ajaxHelper, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.BeginActionLink( actionName, controllerName, protocol, hostName, fragment, new RouteValueDictionary( routeValues ), ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this HtmlHelper htmlHelper, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginActionLink( actionName, controllerName, protocol, hostName, fragment, routeValues, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="routeName">The name of the route to use to obtain the form-post URL.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginRouteForm( this HtmlHelper htmlHelper, string routeName, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginRouteForm( routeName, null, FormMethod.Post, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this HtmlHelper htmlHelper, string actionName, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginActionLink( actionName, null, null, null, null, null, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginForm( this HtmlHelper htmlHelper, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginForm( null, null, routeValues, FormMethod.Post, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="routeName">The name of the route that is used to return a virtual path.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginRouteLink( this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginRouteLink( routeName, null, null, null, routeValues, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action method.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <form> tag.</returns> public static MvcForm BeginForm( this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginForm( actionName, controllerName, new RouteValueDictionary( routeValues ), FormMethod.Post, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="routeName">The name of the route that is used to return a virtual path.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginRouteLink( this HtmlHelper htmlHelper, string routeName, string protocol, string hostName, string fragment, object routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginRouteLink( routeName, protocol, hostName, fragment, new RouteValueDictionary( routeValues ), attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified action. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="routeName">The name of the route that is used to return a virtual path.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString RouteLink( this HtmlHelper htmlHelper, string linkText, string routeName, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.RouteLink( linkText, routeName, null, attributeExpression.GetAttributes() ); }
/// <summary> /// Writes an opening <a> tag to the response. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="actionName">The name of the action.</param> /// <param name="routeValues"> /// An object that contains the parameters for a route. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An opening <a> tag.</returns> public static MvcLink BeginActionLink( this HtmlHelper htmlHelper, string actionName, object routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.BeginActionLink( actionName, null, null, null, null, new RouteValueDictionary( routeValues ), attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified location. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action.</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.ActionLink( linkText, actionName, routeValues, attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element that contains the URL to the specified action method; when the action link is clicked, the action method is invoked asynchronously by using JavaScript. /// </summary> /// <param name="ajaxHelper">The AJAX helper.</param> /// <param name="linkText">The inner text of the anchor element.</param> /// <param name="actionName">The name of the action method.</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="fragment">The URL fragment name (the anchor name).</param> /// <param name="routeValues">An object that contains the parameters for a route.</param> /// <param name="ajaxOptions">An object that provides options for the asynchronous request.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element.</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString ActionLink( this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, Action<HtmlAttributeBuilder> attributeExpression ) { return ajaxHelper.ActionLink( linkText, actionName, controllerName, protocol, hostName, fragment, routeValues, ajaxOptions, attributeExpression.GetAttributes() ); }
/// <summary> /// Returns an anchor element (a element) that contains the virtual path of the specified location. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <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. /// The parameters are retrieved through reflection by examining the properties of the object. /// The object is typically created by using object initializer syntax. /// </param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>An anchor element (a element).</returns> /// <exception cref="T:System.ArgumentException">The <paramref name="linkText" /> parameter is null or empty.</exception> public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.ActionLink( linkText, actionName, controllerName, new RouteValueDictionary( routeValues ), attributeExpression.GetAttributes() ); }
/// <summary> /// Returns a string of HTML attributes with the specified values. /// </summary> /// <param name="htmlHelper">The HTML helper instance that this method extends.</param> /// <param name="attributeExpression">An expression that contains the HTML attributes to set for the element.</param> /// <returns>A string of HTML attributes with the specified values.</returns> public static MvcHtmlString Attributes( this HtmlHelper htmlHelper, Action<HtmlAttributeBuilder> attributeExpression ) { return htmlHelper.Attributes( attributeExpression.GetAttributes() ); }