Exemple #1
0
        /// <summary>
        /// Renders a &lt;form&gt; start tag to the response. The route with name <paramref name="routeName"/>
        /// generates the &lt;form&gt;'s <c>action</c> attribute value.
        /// </summary>
        /// <param name="routeName">The name of the route.</param>
        /// <param name="routeValues">
        /// An <see cref="object"/> that contains the parameters for a route. The parameters are retrieved through
        /// reflection by examining the properties of the <see cref="object"/>. This <see cref="object"/> is typically
        /// created using <see cref="object"/> initializer syntax. Alternatively, an
        /// <see cref="IDictionary{string, object}"/> instance containing the route parameters.
        /// </param>
        /// <param name="method">The HTTP method for processing the form, either GET or POST.</param>
        /// <param name="htmlAttributes">
        /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
        /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
        /// </param>
        /// <returns>
        /// An <see cref="MvcForm"/> instance which renders the &lt;/form&gt; end tag when disposed.
        /// </returns>
        /// <remarks>
        /// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
        /// </remarks>
        protected virtual MvcForm GenerateRouteForm(
            string routeName,
            object routeValues,
            FormMethod method,
            object htmlAttributes)
        {
            var tagBuilder = _htmlGenerator.GenerateRouteForm(
                ViewContext,
                routeName,
                routeValues,
                GetFormMethodString(method),
                htmlAttributes);

            if (tagBuilder != null)
            {
                ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag));
            }

            return(CreateForm());
        }
Exemple #2
0
 public TagBuilder GenerateRouteForm(ViewContext viewContext, string routeName, object routeValues, string method, object htmlAttributes)
 {
     return(_htmlGenerator.GenerateRouteForm(viewContext, routeName, routeValues, method, htmlAttributes));
 }