コード例 #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
ファイル: ElementTesters.cs プロジェクト: ilich/htmltags
        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
ファイル: ElementTesters.cs プロジェクト: ilich/htmltags
        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
ファイル: ElementTesters.cs プロジェクト: ilich/htmltags
        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
ファイル: ElementTesters.cs プロジェクト: ilich/htmltags
        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
ファイル: ElementTesters.cs プロジェクト: denkhaus/htmltags
 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\">");
        }