前台页面
@using (Ajax.BeginForm("ViewSelectCourseInfo", new RouteValueDictionary { { "id", "" } }, new AjaxOptions { UpdateTargetId = "courselist", InsertionMode = InsertionMode.Replace, OnBegin = "InitLoading", OnSuccess = "responsetable" }, new RouteValueDictionary { { "id", "searchForm" } })) { <div class="col-lg-8 col-sm-8 col-md-8 col-xs-8"> <div class="mail-option"> <input type="hidden" id="selectid" name="selectid" value="@ViewBag.selectid" /> <div class="btn-group hidden-phone"> <input type="text" class="form-control search " id="searchname" name="searchname" placeholder="输入课程名称..."> </div> <div class="btn-group hidden-phone"> <a class="btn mini tooltips" href="javascript:void(0);" onclick="refresh()" data-placement="right" data-original-title="刷新"> <i class=" icon-refresh"></i> </a> </div> </div> </div> }
后台代码
[Route("CourseSet/ViewSelectCourseInfo/{selectid}/{id?}")] public ActionResult ViewSelectCourseInfo(string selectid,string searchname = "",int id=1) { if (string.IsNullOrEmpty(selectid)) { Response.Redirect("/CourseSet/SelectCourseIndex"); } ViewBag.selectid = selectid; return AjaxViewCourseInfoPostResult(selectid,searchname, id); } private ActionResult AjaxViewCourseInfoPostResult(string selectid="", string searchname = "", int id = 1) { List<view_course_teacher_info_relation> listCourseInfo = new List<view_course_teacher_info_relation>(); int totalCount = 0, pageSize =STATICPARAM.DEFAULT_PAGE_SIZE; bool isAjax = Request.IsAjaxRequest(); if (isAjax) { listCourseInfo = ViewCourseTeacherInfoRelationBLL.GetCourseInfoListByConditon(currentUserSchoolId, selectid, "",searchname, id, pageSize, ref totalCount); } var model = new PagedList<view_course_teacher_info_relation>(listCourseInfo, id, pageSize, totalCount); ViewBag.count = totalCount; if (isAjax) return PartialView("_LCourseInfoList", model); return View(model); }