ASP.NET MVC 分部页 PartialViewResult
来源:互联网 发布:cp linux 复制文件夹 编辑:程序博客网 时间:2024/09/21 09:03
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);//传入集合aps.net会解析好,然后返回一个页面html }
@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.title4 </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.content4 </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
0 0
- ASP.NET MVC 分部页 PartialViewResult
- ASP.NET MVC 分部页 PartialViewResult
- ASP.NET MVC 3的分部视图
- ASP.NET MVC异步加载分部视图
- ASP.NET MVC 的分部视图
- asp.net mvc 3.0详细笔记__11__创建分部视图
- ASP.NET MVC公共模板、节、分部视图等
- Asp.Net MVC使用分部视图实现二级级联
- Asp.net MVC学习日记八(JQuery和分部视图,查看详细)
- asp.net MVC 中呈现指定区域下的分部视图
- ASP.Net MVC开发基础学习笔记(10):分部视图PartialView
- spring mvc能否实现类似.net mvc的分部视图
- 笔记之一:关于.net MVC的分部视图
- MVC中的分部视图
- MVC分部视图
- MVC |分部视图 PartialView()
- asp.net mvc 起始页
- asp.net mvc 模板页
- memory-map i/o和port-map i/o
- 基于HTML5的可预览多图片Ajax上传
- MySql:操作数据库以及一些常用的命令
- strncpy()函数
- Linux环境学习和开发心得(作者:lunker)
- ASP.NET MVC 分部页 PartialViewResult
- http协议中get和post的区别(转)
- Volley 源码解析
- CodeForces #325 D. Phillip and Trains
- eclipse中注释出现乱码的情况
- android 多线程下载 显示进度 速度
- (四)Intellij 模板注释
- vsftpd 用户访问上级目录
- linux 64 位和32 系统的关于类型的不同