• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FormMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FormMethod的典型用法代码示例。如果您正苦于以下问题:C# FormMethod类的具体用法?C# FormMethod怎么用?C# FormMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormMethod类属于命名空间,在下文中一共展示了FormMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RenderForm

        /// <summary>
        /// This renders out the form for us
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="formAction"></param>
        /// <param name="method"></param>
        /// <param name="htmlAttributes"></param>
        /// <param name="surfaceController"></param>
        /// <param name="surfaceAction"></param>
        /// <param name="area"></param>		
        /// <param name="additionalRouteVals"></param>
        /// <returns></returns>
        /// <remarks>
        /// This code is pretty much the same as the underlying MVC code that writes out the form
        /// </remarks>
        private static MvcForm RenderForm(this IHtmlHelper htmlHelper,
                                          string formAction,
                                          FormMethod method,
                                          IDictionary<string, object> htmlAttributes,
                                          string surfaceController,
                                          string surfaceAction,
                                          string area,
                                          object additionalRouteVals = null)
        {
            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary<string, object>();
            }
            //ensure that the multipart/form-data is added to the html attributes
            if (htmlAttributes.ContainsKey("enctype") == false)
            {
                htmlAttributes.Add("enctype", "multipart/form-data");
            }

            var tagBuilder = new TagBuilder("form");
            tagBuilder.MergeAttributes(htmlAttributes);
            // action is implicitly generated, so htmlAttributes take precedence.
            tagBuilder.MergeAttribute("action", formAction);
            // method is an explicit parameter, so it takes precedence over the htmlAttributes.
            tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);

            tagBuilder.TagRenderMode = TagRenderMode.StartTag;
            tagBuilder.WriteTo(htmlHelper.ViewContext.Writer, new HtmlEncoder());

            //new UmbracoForm:
            var theForm = new UmbracoForm(htmlHelper.UrlEncoder, htmlHelper.ViewContext, surfaceController, surfaceAction, area, additionalRouteVals);

            return theForm;
        }
开发者ID:vnbaaij,项目名称:Umbraco9,代码行数:49,代码来源:HtmlHelperRenderExtensions.cs


示例2: Form

 public Form(ActionResult result)
     : base(null)
 {
     this._result = result;
     this._formMethod = System.Web.Mvc.FormMethod.Post;
     _actionTypePassed = ActionTypePassed.HtmlActionResult;
 }
开发者ID:ngadotnet,项目名称:TwitterBootstrapMvc,代码行数:7,代码来源:Form.cs


示例3: jQueryForm

        public jQueryForm(ViewContext context, string action, FormMethod method, jQueryAjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes)
            : base("form", TagRenderMode.StartTag)
        {


            MergeAttributes(htmlAttributes);
            Method = method;
            Action = action;
            ViewContext = context;
            OriginalFormContext = context.FormContext;
            context.FormContext = new FormContext();
            AjaxOptions = ajaxOptions ?? new jQueryAjaxOptions();

            if (AjaxOptions != null && AjaxOptions.Metadata)
            {
                AddClass("jquery-ajax-form");
                Attributes.Merge("data-jquery-ajax", AjaxOptions.ToJson());
            }

            if (string.IsNullOrWhiteSpace(Id))
            {
                Attributes.Merge("id", string.Format("form{0}", DateTime.UtcNow.Ticks));
            }
            //context.Writer.Write(f.Html(context));
        }
开发者ID:Mangon2015,项目名称:Mangon.FrameWork.MVC,代码行数:25,代码来源:jQueryForm.cs


示例4: 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.</param>
        /// <param name="routeName">The name of the route to use to obtain the form-post URL.</param>
        /// <param name="method">The HTTP method for processing the form, either GET or POST.</param>
        /// <param name="routeValues">An object that contains the parameters for evaluatedValueString route.</param>
        /// <param name="htmlAttributes">The HTTP method for processing the form, either GET or POST.</param>
        /// <returns>An opening form tag.</returns>
        public static IDisposable BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method = FormMethod.Post, object routeValues = null, object htmlAttributes = null)
        {
            var routeDictionary = htmlHelper.AutomaticRouteValuesDictionary(routeValues);
            var attrDictionary = htmlHelper.AutomaticHtmlAttributes(htmlAttributes);

            return BootstrapHelperConfiguration.HtmlRenderer.BeginRouteForm(htmlHelper, routeName, method, routeDictionary, attrDictionary);
        }
开发者ID:steentottrup,项目名称:NBootstrapper,代码行数:17,代码来源:FormExtensions.cs


示例5: With

        /// <summary>
        /// Sets configuration values for the rendered HTML form.
        /// </summary>
        /// <param name="actionName">The name of the target action.</param>
        /// <param name="controllerName">The name of the target controller.</param>
        /// <param name="routeValues">The route values for the target action.</param>
        /// <param name="formMethod">The method used to submit the form.</param>
        /// <param name="cssClass">The element class.</param>
        /// <param name="cssStyle">The element style.</param>
        /// <returns>The configured <see cref="System.Web.Mvc.Html.MvcForm"/> instance.</returns>
        public MvcForm With(
            string actionName = null, 
            string controllerName = null, 
            object routeValues = null, 
            FormMethod formMethod = FormMethod.Post, 
            string cssClass = null, 
            string cssStyle = null)
        {
            base.With(cssClass, cssStyle);

            if (controllerName.IsNullOrEmpty())
            {
                controllerName = this.HtmlHelper.InnerHelper.ViewContext.RouteData.Values["Controller"] as string;
            }

            if (actionName.IsNullOrEmpty())
            {
                actionName = this.HtmlHelper.InnerHelper.ViewContext.RouteData.Values["Action"] as string;
            }

            var htmlAttributes = this.HtmlAttributes;
            var safeRouteValues = new RouteValueDictionary(routeValues);

            MvcForm form;

            form = this.HtmlHelper
                       .InnerHelper
                            .BeginForm(actionName, controllerName, safeRouteValues, formMethod, htmlAttributes);
            
            return form;
        }
开发者ID:ldiego08,项目名称:Flunt.NET,代码行数:41,代码来源:FormHtmlElement.cs


示例6: FormRoute

 public static IDisposable FormRoute(this HtmlHelper html, string routeName, FormMethod method, RouteValueDictionary valuesDictionary) {
     VirtualPathData virtualPath = RouteTable.Routes.GetVirtualPath(html.ViewContext, routeName, valuesDictionary);
     string formAction = (virtualPath == null) ? null : virtualPath.VirtualPath;
     SimpleForm form = new SimpleForm(html.ViewContext.HttpContext, formAction, method, null);
     form.WriteStartTag();
     return form;
 }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:7,代码来源:FormExtensions.cs


示例7: Form

 /// <summary>
 /// Sets action attribute to a form element by using controller and an action method
 /// </summary>
 /// <param name="action"></param>
 /// <param name="controller"></param>
 public Form(string action, string controller)
     : base(null)
 {
     this._action = action;
     this._controller = controller;
     this._formMethod = System.Web.Mvc.FormMethod.Post;
 }
开发者ID:andrewreyes,项目名称:NiftyMvcHelpers,代码行数:12,代码来源:Form.cs


示例8: FormContainer

        public FormContainer(HtmlTextWriter htmlTextWriter,
            string url ,
            BootstrapFormType formType = BootstrapFormType.Horizontal,
            FormMethod method = FormMethod.Post,
            object htmlAttributes = null)
        {
            this.textWriter = htmlTextWriter;
            this.formType = formType;

           // textWriter.AddAttribute("method", method.ToString());

            //textWriter.AddAttribute("action", url ) ;
            var htmlAttributesCollection = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

            switch (this.formType)
            {
                case BootstrapFormType.Horizontal: htmlAttributesCollection.Merge("class", "form-horizontal"); break;
                case BootstrapFormType.Vertical: htmlAttributesCollection.Merge("class", "form-vertical"); break;
                case BootstrapFormType.Inline: htmlAttributesCollection.Merge("class", "form-inline"); break;
            }

            foreach (var htmlAttribute in htmlAttributesCollection)
            {
                textWriter.AddAttribute(htmlAttribute.Key, htmlAttribute.Value.ToString());
            }
            textWriter.RenderBeginTag(HtmlTextWriterTag.Form);
            
        }
开发者ID:AbdoNile,项目名称:Foundation,代码行数:28,代码来源:FormContainer.cs


示例9: Form

 public Form(Task<ActionResult> taskResult)
     : base(null)
 {
     this._taskResult = taskResult;
     this._formMethod = System.Web.Mvc.FormMethod.Post;
     _actionTypePassed = ActionTypePassed.HtmlTaskResult;
 }
开发者ID:joypipi,项目名称:TwitterBootstrapMvc,代码行数:7,代码来源:Form.cs


示例10: BeginForm

 public static MvcForm BeginForm( this HtmlHelper htmlHelper,
                                  String actionName,
                                  String controllerName,
                                  FormMethod method,
                                  Hash htmlAttributes )
 {
     return htmlHelper.BeginForm(actionName, controllerName, method, HashHelper.ToStringKeyDictinary( htmlAttributes ));
 }
开发者ID:peterjoh,项目名称:NHaml,代码行数:8,代码来源:BooFormExtensions.cs


示例11: Init

 private void Init(HtmlHelper html, string actionName = null, string controllerName = null, object routeValues = null,
                   FormMethod method = FormMethod.Post, object htmlAttrs = null, FormType? formType = null)
 {
     var attrs = new HtmlAttributes(htmlAttrs);
     if (formType != null) attrs["class"] += "form-" + formType.ToString().ToLower();
     if (html == null) return;
     _form = html.BeginForm(actionName, controllerName, new RouteValueDictionary(routeValues), method, attrs.ToDictionary());
 }
开发者ID:FerozAhmed,项目名称:bootstrapcomponents,代码行数:8,代码来源:Form.cs


示例12: CarcassBeginForm

 /// <summary>
 /// Writes an opening &lt;form&gt; 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="formClass">CSS class for <c>form</c> element</param>
 /// <param name="method">The HTTP method for processing the form, either GET or POST.</param>
 /// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param>
 /// <returns>An opening <form> tag</returns>
 public static CarcassMvcForm CarcassBeginForm(this HtmlHelper htmlHelper,
     string formClass = CarcassMvcSettings.BootsrapFormClassHorisontal, 
     FormMethod method = FormMethod.Post,
     object htmlAttributes = null)
 {
     var rawUrl = htmlHelper.ViewContext.HttpContext.Request.RawUrl;
     return CarcassBeginFormImpl(htmlHelper, rawUrl, formClass, method, (IDictionary<string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
 }
开发者ID:kamaelyoung,项目名称:Carcass,代码行数:17,代码来源:FormExtensions.cs


示例13: BeginForm

 public static MvcForm BeginForm(
     [NotNull] this IHtmlHelper htmlHelper,
     FormMethod method,
     object htmlAttributes)
 {
     return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
                                 method: method, htmlAttributes: htmlAttributes);
 }
开发者ID:Nakro,项目名称:Mvc,代码行数:8,代码来源:HtmlHelperFormExtensions.cs


示例14: Button

        public static MvcHtmlString Button(this HtmlHelper helper, 
            string text, string urlAction, FormMethod method, object htmlAttributes)
        {
            var tagBuilder = new TagBuilder("input");
            FillWithAttributes(tagBuilder, new { type = "submit", formaction = urlAction, formmethod = method.ToString(), value = text });
            FillWithAttributes(tagBuilder, htmlAttributes);

            return new MvcHtmlString(tagBuilder.ToString());
        }
开发者ID:tEkaterina,项目名称:photoalbum,代码行数:9,代码来源:HtmlExtension.cs


示例15: BeginAngularForm

        public static MsAspMvc.MvcForm BeginAngularForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes)
        {
            RouteValueDictionary routeValues = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
            if (!routeValues.ContainsKey("name"))
                routeValues.Add("name", "form");

            htmlHelper.ViewData.Add("formName", routeValues["name"]);
            return MsAspMvc.FormExtensions.BeginForm(htmlHelper, actionName, controllerName, method, routeValues);
        }
开发者ID:cstruter,项目名称:angularjs-aspnet-mvc,代码行数:9,代码来源:FormExtensions.cs


示例16: BeginForm

        /// <summary>
        /// Renders a &lt;form&gt; start tag to the response. When the user submits the form, the
        /// current action will process the request.
        /// </summary>
        /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
        /// <param name="method">The HTTP method for processing the form, either GET or POST.</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>
        public static MvcForm BeginForm(this IHtmlHelper htmlHelper, FormMethod method)
        {
            if (htmlHelper == null)
            {
                throw new ArgumentNullException(nameof(htmlHelper));
            }

            return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
                                        method: method, htmlAttributes: null);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:22,代码来源:HtmlHelperFormExtensions.cs


示例17: MyBeginForm

 public static IDisposable MyBeginForm(this HtmlHelper html, string action, string controller, FormMethod method)
 {
     var routeValues = new RouteValueDictionary();
     var query = html.ViewContext.HttpContext.Request.QueryString;
     foreach (string key in query)
     {
         routeValues[key] = query[key];
     }
     return html.BeginForm(action, controller, routeValues, FormMethod.Get);
 }
开发者ID:customsoftbde,项目名称:Copy-of-MealsToGo,代码行数:10,代码来源:BeginFormHelper.cs


示例18: FormHelper

 /// <summary>
 /// Invokes the private static "FormHelper" method of the <see cref="T:System.Web.Mvc.Html.FormExtensions" /> class via reflection.
 /// </summary>
 /// <param name="htmlHelper">The HTML helper.</param>
 /// <param name="formAction">The form action.</param>
 /// <param name="method">The method.</param>
 /// <param name="htmlAttributes">The HTML attributes.</param>
 /// <returns></returns>
 public static MvcForm FormHelper(HtmlHelper htmlHelper,
                                  string formAction,
                                  FormMethod method,
                                  IDictionary<string, object> htmlAttributes)
 {
     return (MvcForm) typeof (FormExtensions).InvokeMember("FormHelper",
                                                           BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod,
                                                           null,
                                                           null,
                                                           new object[] {htmlHelper, formAction, method, htmlAttributes});
 }
开发者ID:isannn,项目名称:Build.Mvc,代码行数:19,代码来源:BuildHelpers.cs


示例19: Form

 public override MvcHtmlString Form(String url, Object routeValues, FormMethod formMethod, Object htmlAttribute, String innerHtml)
 {
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.Append("<form ");
     stringBuilder.Append(TagHelper.PackHtmlAttrbute(htmlAttribute));
     stringBuilder.Append(String.Concat(TagHelper.PackFormMethod(formMethod), " "));
     stringBuilder.Append(TagHelper.PackAction(url, routeValues));
     stringBuilder.AppendLine(">");
     stringBuilder.AppendLine(innerHtml);
     stringBuilder.Append("</form>");
     return MvcHtmlString.Create(stringBuilder.ToString());
 }
开发者ID:zformular,项目名称:ValueHelper,代码行数:12,代码来源:MvcTwTagHtml.cs


示例20: PantherForm

        public static MvcForm PantherForm(this IHtmlHelper htmlHelper, string Path, FormMethod method = FormMethod.Post, IDictionary<string, object> htmlAttributes = null)
        {
            
            TagBuilder builder = new TagBuilder("form");
            builder.MergeAttributes(htmlAttributes);
            builder.MergeAttribute("action", Path);
            builder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);

            htmlHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag));

            return new MvcForm(htmlHelper.ViewContext);
        }
开发者ID:freemsly,项目名称:CMS,代码行数:12,代码来源:PantherHelper.Form.cs



注:本文中的FormMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FormTypes类代码示例发布时间:2022-05-24
下一篇:
C# FormInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap