本文整理汇总了C#中this.BeginRouteForm方法的典型用法代码示例。如果您正苦于以下问题:C# this.BeginRouteForm方法的具体用法?C# this.BeginRouteForm怎么用?C# this.BeginRouteForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.BeginRouteForm方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginResourceForm
/// <summary>
/// Generates the Form preamble
/// </summary>
/// <param name="html"></param>
/// <param name="controllerName"></param>
/// <param name="routeValues"></param>
/// <param name="htmlAttributes"></param>
/// <param name="actionType"></param>
/// <returns></returns>
public static MvcForm BeginResourceForm(this HtmlHelper html, string controllerName, object routeValues, object htmlAttributes, ActionType actionType) {
switch (actionType) {
case ActionType.GetUpdateForm:
return html.BeginRouteForm(controllerName + "-editForm", routeValues, FormMethod.Post, htmlAttributes);
case ActionType.GetCreateForm:
return html.BeginRouteForm(controllerName + "-createForm", FormMethod.Post, htmlAttributes);
case ActionType.Retrieve:
case ActionType.Delete:
case ActionType.Update:
return html.BeginRouteForm(controllerName, routeValues, FormMethod.Post, htmlAttributes);
case ActionType.Create:
return html.BeginRouteForm(controllerName + "-create", FormMethod.Post, htmlAttributes);
case ActionType.Index:
return html.BeginRouteForm(controllerName + "-index", FormMethod.Post, htmlAttributes);
default:
throw new ArgumentOutOfRangeException("actionType");
}
}
示例2: BeginResourceForm
/// <summary>
/// Generates the Form preamble
/// </summary>
/// <param name="ajax"></param>
/// <param name="controllerName"></param>
/// <param name="routeValues"></param>
/// <param name="ajaxOptions"></param>
/// <param name="actionType"></param>
/// <returns></returns>
public static MvcForm BeginResourceForm(this AjaxHelper ajax, string controllerName, object routeValues, AjaxOptions ajaxOptions, ActionType actionType) {
switch (actionType) {
case ActionType.GetUpdateForm:
return ajax.BeginRouteForm(controllerName + "-editForm", routeValues, ajaxOptions);
case ActionType.GetCreateForm:
return ajax.BeginRouteForm(controllerName + "-createForm", ajaxOptions);
case ActionType.Retrieve:
case ActionType.Delete:
case ActionType.Update:
// can we use ajaxOptions to either add the header?
MvcForm form = ajax.BeginRouteForm(controllerName, routeValues, ajaxOptions);
return form;
case ActionType.Create:
return ajax.BeginRouteForm(controllerName + "-create", ajaxOptions);
case ActionType.Index:
return ajax.BeginRouteForm(controllerName + "-index", ajaxOptions);
default:
throw new ArgumentOutOfRangeException("actionType");
}
}
示例3: BeginERPStoreRouteForm
public static MvcForm BeginERPStoreRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method)
{
routeName = htmlHelper.ResolveRouteName(routeName);
return htmlHelper.BeginRouteForm(routeName, routeValues, method);
}
示例4: BeginRouteTokenForm
public static MvcForm BeginRouteTokenForm(this HtmlHelper htmlHelper, string routeName)
{
var mvcForm = htmlHelper.BeginRouteForm(routeName);
htmlHelper.ViewContext.Writer.Write(htmlHelper.AntiForgeryToken().ToHtmlString());
return mvcForm;
}
示例5: BeginRouteForm
/// <summary>
/// Renders a <form> start tag to the response. The route with name <paramref name="routeName"/>
/// generates the <form>'s <c>action</c> attribute value.
/// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="routeName">The name of the route.</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="System.Collections.Generic.IDictionary{string, object}"/> instance containing the HTML
/// attributes.
/// </param>
/// <returns>
/// An <see cref="MvcForm"/> instance which renders the </form> end tag when disposed.
/// </returns>
/// <remarks>
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
/// </remarks>
public static MvcForm BeginRouteForm(
this IHtmlHelper htmlHelper,
string routeName,
FormMethod method,
object htmlAttributes)
{
if (htmlHelper == null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
return htmlHelper.BeginRouteForm(
routeName,
routeValues: null,
method: method,
htmlAttributes: htmlAttributes);
}
示例6: BeginRouteForm
/// <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() );
}
示例7: BeginRouteForm
public static MvcForm BeginRouteForm(this AjaxHelper ajaxHelper, string routeName, Task<ActionResult> taskResult, AjaxOptions ajaxOptions)
{
return ajaxHelper.BeginRouteForm(routeName, taskResult.Result, ajaxOptions, null);
}
示例8: FormRoute
public static IDisposable FormRoute(this HtmlHelper html, string routeName, FormMethod method, RouteValueDictionary valuesDictionary)
{
VirtualPathData virtualPath = RouteTable.Routes.GetVirtualPath(html.ViewContext.RequestContext, routeName, valuesDictionary);
string formAction = (virtualPath == null) ? null : virtualPath.VirtualPath;
return html.BeginRouteForm(routeName, method, valuesDictionary);
}
示例9: BeginLocalizedRouteForm
public static MvcForm BeginLocalizedRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method)
{
var currentLanguage = GetCurrentLanguage(htmlHelper);
routeName = string.Format("{0}-{1}", routeName, currentLanguage);
return htmlHelper.BeginRouteForm(routeName, routeValues, method);
}
示例10: SecureBeginRouteForm
public static MvcForm SecureBeginRouteForm(this HtmlHelper htmlHelper, string routeName, ActionResult result, FormMethod method, IDictionary<string, object> htmlAttributes)
{
return htmlHelper.BeginRouteForm(routeName, result.GetRouteValueDictionary(), method, htmlAttributes);
}
示例11: BeginRouteForm
/// <summary>
/// Renders a <form> start tag to the response. The route with name <paramref name="routeName"/>
/// generates the <form>'s <c>action</c> attribute value.
/// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="routeName">The name of the route.</param>
/// <param name="suppressAntiforgery">
/// If <c>true</c>, suppresses the generation an <input> of type "hidden" with an antiforgery token. By
/// default <form> elements will automatically include an antiforgery token.
/// </param>
/// <returns>
/// An <see cref="MvcForm"/> instance which renders the </form> end tag when disposed.
/// </returns>
/// <remarks>
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
/// </remarks>
public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, bool suppressAntiforgery)
{
if (htmlHelper == null)
{
throw new ArgumentNullException(nameof(htmlHelper));
}
return htmlHelper.BeginRouteForm(
routeName,
routeValues: null,
method: FormMethod.Post,
suppressAntiforgery: suppressAntiforgery,
htmlAttributes: null);
}