zoukankan      html  css  js  c++  java
  • MVC中,查询以异步呈现,分页不用异步的解决方案

    这种需求,用一个ASPX页面和一个ASCX分部视图就可以解决了,ASPX提供对ASCX的引用,ASCX显示列表信息,ASPX主页面提供查询功能

      <% using (Html.BeginForm())
           {%>
        <%Html.RenderAction("AllPropertyForSelectList", "Common"); %><input type="button"
            value="查询" class="button" id="search" />
        <div id="list">
            <%Html.RenderPartial("Common_BasePropValueList",Model); %>
        </div>
        <%} %>

    查询功能的JS

    <script type="text/javascript">
            $(function () {
                $("#search").click(function () {
                    $.ajax({
                        type: "POST",
                        url: "/Common_BaseProp/Index",
                        data: { page: "<%=Model.PageIndex %>", pid: $("#PID").val() },
                        success: function (data) {
                            $("#list").html(data);
                        }
                    })
                });
            });
        </script>

    controller代码:

      public ActionResult Index(int? page, int? pid)
            {
                vp = new Entity.VPredication();
                pp = new Entity.PagingParam(page ?? 1, PAGESIZE);
                if (pid != null)
                    vp.AddItem("pid", pid);
                Entity.PagedList<Common_BasePropValue_Ext> model = iCommon_BasePropValueService.GetAllBasePropValue(vp, pp);
                if (Request.IsAjaxRequest()) //通过判断请求,来确定是返回页面,还是返回分部视图
                    return PartialView("Common_BasePropValueList",model);
                else
                    return View(model);
            }

  • 相关阅读:
    建筑名称解释
    delphi 文件查找
    bat如何批量删除指定部分文件夹名的文件夹
    在 DELPHI 中 procedure 型变量与 method 型变量的区别
    Spearman Rank(斯皮尔曼等级)相关系数
    机器学习的MLE和MAP:最大似然估计和最大后验估计
    error “Device supports x86, but APK only supports armeabi-v7a”
    windows 安装ninja
    Gradle语法基础解析
    executing external native build for cmake
  • 原文地址:https://www.cnblogs.com/lori/p/2267474.html
Copyright © 2011-2022 走看看