Пример #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 void form_action_can_be_specified_via_constructor()
        {
            var tag = new FormTag("/user/create");

            tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"post\" action=\"/user/create\">");
        }
Пример #3
0
        public void form_id_can_be_customized()
        {
            var tag = new FormTag().Id("other-form");

            tag.ToString().ShouldEqual("<form id=\"other-form\" method=\"post\">");
        }
Пример #4
0
        public void form_method_can_be_customized()
        {
            var tag = new FormTag().Method("get");

            tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"get\">");
        }
Пример #5
0
 public void form_tag_creates_the_opening_element_of_a_form_with_id_mainForm()
 {
     var tag = new FormTag();
     tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"post\">");
 }
Пример #6
0
        public void form_tag_creates_the_opening_element_of_a_form_with_id_mainForm()
        {
            var tag = new FormTag();

            tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"post\">");
        }
Пример #7
0
 public void form_method_can_be_customized()
 {
     var tag = new FormTag().Method("get");
     tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"get\">");
 }
Пример #8
0
 public void form_id_can_be_customized()
 {
     var tag = new FormTag().Id("other-form");
     tag.ToString().ShouldEqual("<form id=\"other-form\" method=\"post\">");
 }
Пример #9
0
 public void form_action_can_be_specified_via_constructor()
 {
     var tag = new FormTag("/user/create");
     tag.ToString().ShouldEqual("<form id=\"mainForm\" method=\"post\" action=\"/user/create\">");
 }
Пример #10
0
 public void form_action_can_be_specified()
 {
     var tag = new FormTag().Action("/user/create");
     tag.ToString().ShouldEqual("<form method=\"post\" action=\"/user/create\">");
 }
Пример #11
0
        public void form_action_can_be_specified()
        {
            var tag = new FormTag().Action("/user/create");

            tag.ToString().ShouldEqual("<form method=\"post\" action=\"/user/create\">");
        }