MVC中的提交数据。自己理解

             方式一:<input type="submit" class="u-btnblue" value="保存" />

                            好处:验证直接用实体就可以

                             缺点:验证不能多样化,不是很灵活哦。

              方式二: <input type="button" class="u-btnblue" value="添加关键词" id="AddKeyWords" />

                                $("#AddoldNode").click(function () {

            if ("0" == $("#hfTextBookID").val()) {
                top.art.dialog({
                    title: '消息',
                    content: '请先选择书本!',
                    icon: 'warning',
                    ok: function () {

                    }
                });
                return false;
            }

            
            var location = encodeURI("/Admin/Catalog/GetKnoledgeSecond?strBookID=" + $("#hfTextBookID").val();
            $.getJSON(location,
                        function (data) {
                            if (data != null || data != "") {
                                zNodes = data;

                            }
        
                        }
                    );


        });


     好处:可以自己写验证

       缺点:只能一次提交

方式三:利用AjaxSUbmit

           步骤一:<script language="JavaScript" src="@Web.APP_Configs.ProgramConfig.JScriptAddress/Admin/jquery.form.js" type="text/javascript"></script>

           步骤二:@using (Html.BeginForm("Add", "Book", FormMethod.Post, new { id = "textBook",enctype = "multipart/form-data" })){}

           步骤三: <input type="button" class="u-btnblue" value="保存"  id="save"/>

        $("#save").click(function () {
            if ($("#nSDescribe").val().replace(/\s+/g, "") == "") {

                $("#testnSDescribe").html("*此项不可为空!");
                return false;
            } else {
                if ($("#nSDescribe").val().replace(/\s+/g, "").length > 2000) {
                    $("#testnSDescribe").html("*此项不可大于2000!");
                    return false;
                } else {
                    $("#testnSDescribe").html("");

                }

            }


            $("#textBook").ajaxSubmit({
                url: "/Admin/Book/Add",
                type: "post",
                success: function (msg) {
                    if (msg == "1") {
                        top.art.dialog({
                            title: '消息',
                            content: '添加成功!',
                            icon: 'succeed',
                            ok: function () {
                                window.location.href = "/Admin/Book/Index"
                            },
                            close: function () {
                                window.location.href = "/Admin/Book/Index"
                            }

                        })
                    }
                    else {
                        top.art.dialog({
                            title: '消息',
                            content: '添加失败!',
                            icon: 'error',
                            ok: function () {

                            }
                        })

                    }
                }
            });

        });



    });

          好处:验证灵活,想什么时候提交就什么时候提交

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值