示例#1
0
        public static MvcForm BeginForm(this HtmlHelper html, string controller = null, string action = null, Action <FormTag> config = null, object routeValues = null)
        {
            var form = new FormTag();

            form.Method("POST");

            if (controller.IsNullOrEmpty())
            {
                controller = html.ViewContext.GetControllerName();
            }

            if (action.IsNullOrEmpty())
            {
                action = html.ViewContext.GetActionName();
            }

            if (config != null)
            {
                config(form);
            }
            form.Action(UrlHelper.GenerateUrl(null, action, controller, new RouteValueDictionary(routeValues),
                                              html.RouteCollection, html.ViewContext.RequestContext, true));
            form.NoClosingTag();
            html.ViewContext.Writer.Write(form.ToString());
            return(new MvcForm(html.ViewContext));
        }
示例#2
0
 public static FormTag DoGET(this FormTag tag)
 {
     return(tag.Method("GET"));
 }
示例#3
0
        //public static ValidationMessageTag CreateValidationTag(this HtmlTag tag, ModelInfo info)
        //{
        //    var errMsg = "";
        //    if (info.ValidationFailed)
        //    {
        //        errMsg = info.ModelErrors[0].ErrorMessage;
        //    }
        //    return new ValidationMessageTag(info.HtmlId, info.ValidationFailed, errMsg);
        //}

        public static FormTag DoPOST(this FormTag tag)
        {
            return(tag.Method("POST"));
        }