PartialViewResult返回的也是一个页面,可以使用@Html.Partial加载这个部分页面,需要多次使用的时候可以用到他
- public PartialViewResult _pxcx(string polName, string podName, string carrCode, string lineName, int page = 1)
- {
- int total = 0;
- var list = _Price_InfoManagement.GetDTO_PRICELCL_List(polName, podName, carrCode, "", "", lineName, "", page, pageSize, out total);
- ViewBag.Pager = PagerHelper.CreatePagerByAjax(page, pageSize, total, "lcl.priceQuery", false, lang == "CN");
- return PartialView(list);
- }
- @model List<GTDesk.Domain.MainModule.Entities.DTO.DTO_C_PRICE>
- <table width="100%" border="0" class="lcl-table tac">
- <tr id="thead">
- <th scope="col">@ViewData["起始港"]</th>
- <th scope="col">@ViewData["目的港"]</th>
- <th scope="col">@ViewData["船公司"]</th>
- <th scope="col">@ViewData["船期"]</th>
- <th scope="col">@ViewData["航程"]</th>
- <th scope="col">@ViewData["中转港"]</th>
- <th scope="col">20GP</th>
- <th scope="col">40GP</th>
- <th scope="col">40HQ</th>
- <th scope="col">@ViewData["附加费"]</th>
- <th scope="col">@ViewData["有效日期"]</th>
- <th scope="col">@ViewData["Key_BookOnline"]</th>
- </tr>
-
- @if (Model != null && Model.Any())
- {
- foreach (var item in Model)
- {
- <tr>
-
- <td>@item.POL_NAME_EN</td>
- <td>@item.POD_NAME_EN</td>
- <td>@item.CARR_CODE</td>
- <td>@item.ETD </td>
- <td>@item.TRANSIT_TIME</td>
- <td>@(string.IsNullOrEmpty(item.POT_NAME_EN) ? "直达" : item.POT_NAME_EN)</td>
- <td> <p class="wz2">@(item.PR_PRICE_20.HasValue?item.PR_PRICE_20.Value.ToString("00"):"")</p></td>
- <td><p class="wz2">@(item.PR_PRICE_40.HasValue?item.PR_PRICE_40.Value.ToString("00"):"")</p></td>
- <td><p class="wz2">@(item.PR_PRICE_40HQ.HasValue?item.PR_PRICE_40HQ.Value.ToString("00"):"")</p></td>
加载部分页面
@Html.Partial("_pxcx", Model)
分页的时候其实就是改变的中间这一块,可以用ajax请求_pxcx,返回的是html在用js这返回的html加载到需要的地方就可以了
-
- var lcl = {
-
- priceQuery: function (index) {
- var polName = $("#POL_NAME_EN").combogrid('getValue');
- var lineName = $("#LineId").combobox('getValue');
- var podName = $('#POD_NAME_EN').combogrid('getValue');
- var carrCode = $('#CARR_CODE').combogrid('getValue');
- $.post('/home/_pxcx', { polName: polName, podName: podName, carrCode: carrCode, lineName: lineName, week: '', boxType: '', page: index }, function (data) {
- $('#price_box').html(data);
- });
- }
- };
所以用zazor在后台组织数据返回的页面,也是可以实现ajax分页的
加载方式
@RenderPage()
但它不能使用 原来视图的 Model 和 ViewData ,只能通过参数来传递。
1 @RenderPage("~/Shared/Component/Dialog.cshtml", new { title = "Hello world!", content="Nani" })
分部视图接收数据通过Page
1 <div id="dialog" title="@Page.title" style="display: none;">
2 <p>
3 @Page.title
4 </p>
5 </div>
@Html.Partial()
用于将分部视图渲染为字符串
@Html.Partial("_PartialPage1",model,ViewData)直接返回MvcHtmlString填充
1 @Html.Partial("Component/Dialog", null, new ViewDataDictionary { { "title", "Hello world!" }, { "content", "Nani?" } })
Razor子视图里使用 ViewBag 来获取传递的数据
1 <div id="dialog" title="@ViewBag.title" style="display: none;">
2 <p>
3 @ViewBag.content
4 </p>
5 </div>
传递强类型到部分视图
1 @{
2 var args = new Dictionary<string,string>();
3 args["redirectController"] = "Admin";
4 args["redirectAction"] = "User";
5 }
6 @Html.Partial("_childPartial",args)
_childPartial.cshtml
1 @model Dictionary<string,string>
2 <div>@Model["redirectController"]</div>
3 <div>@Model["redirectAction"]</div>
@RenderPartial()
http://www.cnblogs.com/raohuagang/p/3740353.html
PartialViewResult返回的也是一个页面,可以使用@Html.Partial加载这个部分页面,需要多次使用的时候可以用到他
- public PartialViewResult _pxcx(string polName, string podName, string carrCode, string lineName, int page = 1)
- {
- int total = 0;
- var list = _Price_InfoManagement.GetDTO_PRICELCL_List(polName, podName, carrCode, "", "", lineName, "", page, pageSize, out total);
- ViewBag.Pager = PagerHelper.CreatePagerByAjax(page, pageSize, total, "lcl.priceQuery", false, lang == "CN");
- return PartialView(list);
- }
- @model List<GTDesk.Domain.MainModule.Entities.DTO.DTO_C_PRICE>
- <table width="100%" border="0" class="lcl-table tac">
- <tr id="thead">
- <th scope="col">@ViewData["起始港"]</th>
- <th scope="col">@ViewData["目的港"]</th>
- <th scope="col">@ViewData["船公司"]</th>
- <th scope="col">@ViewData["船期"]</th>
- <th scope="col">@ViewData["航程"]</th>
- <th scope="col">@ViewData["中转港"]</th>
- <th scope="col">20GP</th>
- <th scope="col">40GP</th>
- <th scope="col">40HQ</th>
- <th scope="col">@ViewData["附加费"]</th>
- <th scope="col">@ViewData["有效日期"]</th>
- <th scope="col">@ViewData["Key_BookOnline"]</th>
- </tr>
-
- @if (Model != null && Model.Any())
- {
- foreach (var item in Model)
- {
- <tr>
-
- <td>@item.POL_NAME_EN</td>
- <td>@item.POD_NAME_EN</td>
- <td>@item.CARR_CODE</td>
- <td>@item.ETD </td>
- <td>@item.TRANSIT_TIME</td>
- <td>@(string.IsNullOrEmpty(item.POT_NAME_EN) ? "直达" : item.POT_NAME_EN)</td>
- <td> <p class="wz2">@(item.PR_PRICE_20.HasValue?item.PR_PRICE_20.Value.ToString("00"):"")</p></td>
- <td><p class="wz2">@(item.PR_PRICE_40.HasValue?item.PR_PRICE_40.Value.ToString("00"):"")</p></td>
- <td><p class="wz2">@(item.PR_PRICE_40HQ.HasValue?item.PR_PRICE_40HQ.Value.ToString("00"):"")</p></td>
加载部分页面
@Html.Partial("_pxcx", Model)
分页的时候其实就是改变的中间这一块,可以用ajax请求_pxcx,返回的是html在用js这返回的html加载到需要的地方就可以了
-
- var lcl = {
-
- priceQuery: function (index) {
- var polName = $("#POL_NAME_EN").combogrid('getValue');
- var lineName = $("#LineId").combobox('getValue');
- var podName = $('#POD_NAME_EN').combogrid('getValue');
- var carrCode = $('#CARR_CODE').combogrid('getValue');
- $.post('/home/_pxcx', { polName: polName, podName: podName, carrCode: carrCode, lineName: lineName, week: '', boxType: '', page: index }, function (data) {
- $('#price_box').html(data);
- });
- }
- };
所以用zazor在后台组织数据返回的页面,也是可以实现ajax分页的
加载方式
@RenderPage()
但它不能使用 原来视图的 Model 和 ViewData ,只能通过参数来传递。
1 @RenderPage("~/Shared/Component/Dialog.cshtml", new { title = "Hello world!", content="Nani" })
分部视图接收数据通过Page
1 <div id="dialog" title="@Page.title" style="display: none;">
2 <p>
3 @Page.title
4 </p>
5 </div>
@Html.Partial()
用于将分部视图渲染为字符串
@Html.Partial("_PartialPage1",model,ViewData)直接返回MvcHtmlString填充
1 @Html.Partial("Component/Dialog", null, new ViewDataDictionary { { "title", "Hello world!" }, { "content", "Nani?" } })
Razor子视图里使用 ViewBag 来获取传递的数据
1 <div id="dialog" title="@ViewBag.title" style="display: none;">
2 <p>
3 @ViewBag.content
4 </p>
5 </div>
传递强类型到部分视图
1 @{
2 var args = new Dictionary<string,string>();
3 args["redirectController"] = "Admin";
4 args["redirectAction"] = "User";
5 }
6 @Html.Partial("_childPartial",args)
_childPartial.cshtml
1 @model Dictionary<string,string>
2 <div>@Model["redirectController"]</div>
3 <div>@Model["redirectAction"]</div>
@RenderPartial()
http://www.cnblogs.com/raohuagang/p/3740353.html