乏mily

导航

无刷新 checkbox列表的删除

前台 JS :

 function ModelDelete() {
            var checkvalues = null;
            var checValue = $("#dom1").find(":checkbox");
            for (var i = 0; i < checValue.length; i++) {
                if (checValue[i].checked == true) {
                    if (checkvalues == null) {
                        checkvalues = checValue[i].value + ",";
                    }
                    else {
                        checkvalues += checValue[i].value + ",";
                    }
                }
            }
            if (checkvalues == null || checkvalues == "") {
                alert("请选择删除的数据");
            }
            else {
                checkvalues = checkvalues.substring(0, checkvalues.lastIndexOf(","));
                $.ajax({
                    type: "POST",
                    url: 'ProComparisonsAdd.aspx/TemDetele',
                    contentType: "application/json",
                    dataType: "json",
                    data: "{TemID:'" + checkvalues + "'}",
                    cache: false,
                    success: function (response) {
                        if (response != "") {
                            $("#dom1").html(response.d);
                        }
                    },
                    error: function (data) {
                        alert("加载失败");
                    }
                });
            }
        }

前台 HTML :

<input id="btn1" type="button" value="删除" onclick="ModelDelete()" style="width: 70px;" />
<div id="dom1">
    <uc1:TemPlan ID="TemPlan1" runat="server">
</div>


后台代码:

        [WebMethod]//删除临时信息
        public static string TemDetele(string TemID)
        {
            XieKe.BLL.tb_PlanDetail tplan = new XieKe.BLL.tb_PlanDetail();
            tplan.Delete_TemList(TemID);
            Page page = new Page();
            TemPlan tem = (TemPlan)page.LoadControl("~/Web.JYK/TemPlan.ascx");
            tem.PageSort = "ProComparisionsAdd";
            page.Controls.Add(tem);
            StringWriter writer = new StringWriter();
            //加载 当前页面 的临时数据
            HttpContext.Current.Server.Execute(page, writer, false);
            return writer.ToString();
        }

 

 

posted on 2013-09-29 10:36  乏mily  阅读(216)  评论(0编辑  收藏  举报