日期:2014-05-17  浏览次数:20419 次

使用MvcPager分布控件的困扰
在用MvcPager分页控件时,做查询用的是URL保存查询参数,还是先上图比较清楚.图1



由于第一次占查询时,后台能用FORM["参数"]取到POST过来的值,同时在分页控件中我加了方法,后面的2、3、4...页URL中保存了查询参数值,图2(第二页,URL改变了,查询值也保存了)



现在去除,来电原因在查询时,由于URL没变,所以来电原因文本框中还是显示了查询前的值(常用查询),蛋疼的问题,我在想点击submit时如何能把URL重置为最初始时没有带参数的状态.如http://localhost:1249/.这样就不会在保存查询前的值.
前台代码:
HTML code

@using(Html.BeginForm()){
        <tr>
            <td class="style2" valign="middle">
                查询条件
            </td>
            <td class="style1" valign="middle">
               
                <div style="line-height:25px;float:left">
                    地市 :@Html.CheckBoxLists("P000", ViewBag.DS as IEnumerable<SelectListItem>, null)<br />
                    地市 :@Html.CheckBoxLists("P001",ViewBag.PP as IEnumerable<SelectListItem>,null)
                </div>
                
                <div style="line-height:50px;float:left;margin-left:20px">
                    来电原因 : <input id="P002" name="P002" type="text" value="@Request["P002"]" />
                </div>
            </td>
            <td class="tdqcss" valign="middle"  style="width:*">
                <input type="submit" value="查询" class="btcss" />
            </td>
            </tr>}


后台
C# code

[HttpGet]
        public ActionResult Index(int pageIndex = 1)
        {
            int total = 0;
            //绑定地市
            ViewBag.PP = PP(false);
            //绑定品牌
            ViewBag.DS = DS(false);
            if(!string.IsNullOrEmpty(Request["t001"]))
            total = Convert.ToInt32(System.Text.Encoding.Default.GetString(Convert.FromBase64String(Request.QueryString["t001"].ToString().Replace("%2B", "+"))));
            //查询条件
            string[] param = Param(Request.QueryString);
            IList<T002> l = GetList(out total, param[0], pageIndex);
            PagedList<T002> lto = new PagedList<T002>(l, pageIndex, 30, total, param[1]);
            return View(lto);
        }
        [HttpPost]
        public ActionResult Index()
        {
            int total = 0;
            //绑定地市
            ViewBag.PP = PP(true);
            //绑定品牌
            ViewBag.DS = DS(true);
            //查询条件
            string[] param = Param(Request.Form);
            IList<T002> l = GetList(out total, param[0], 1);
            PagedList<T002> lto = new PagedList<T002>(l, 1, 30, total, param[1]);
            return View("Index",lto);
        }


求真象!!!

------解决方案--------------------
http://kb.cnblogs.com/a/1765384/
------解决方案--------------------
汗,post和get方式,你弄混淆了. form里面设置用get方式提交把