简体   繁体   English

MVC部分页面刷新

[英]MVC Partial Page Refresh

I am using MVC 5 to render an initial view and Kendo MVVM with WebApi to populate controls with data. 我正在使用MVC 5渲染初始视图,并使用带有WebApi Kendo MVVM来向控件填充数据。 The view returned from the controller is essentially a SPA application. 从控制器返回的视图本质上是SPA应用程序。 After the initial render of the view all further activity on the page is achieved via Kendo MVVM and WebApi (client side script). 初始呈现视图后,页面上的所有其他活动均通过Kendo MVVMWebApi (客户端脚本)实现。

The menu for the application initially used @Url.Action links to present a new View. 该应用程序的菜单最初使用@Url.Action链接来呈现一个新的View。 The issue with this approach is that a full page refresh redraws the entire screen including top and side navs every time an action link is clicked. 这种方法的问题在于,每次单击动作链接时,刷新整个页面都会重新绘制整个屏幕,包括顶部和侧面导航。

I replaced the @Url.Action links with @Ajax.ActionLink and modified the controllers to return Partial Views. 我更换了@Url.Action的链接@Ajax.ActionLink和修改控制器返回局部视图。 The @Ajax.ActionLink enables the rendering of the Partial View into a target Html element ( div ). @Ajax.ActionLink允许将部分视图呈现到目标HTML元素( div )。

Given the application is essentially a Html 5 application rather than a pure MVC application, is this the best way to avoid full page refresh on selection of a new menu item? 考虑到该应用程序本质上是Html 5应用程序,而不是纯MVC应用程序,这是避免在选择新菜单项时刷新整个页面的最佳方法吗?

Secondly, should I be using RenderBody() or is there a better approach? 其次,我应该使用RenderBody()还是有更好的方法?

regards Barry 问候巴里

Try This sample jquery Code Button Or Any control click Or Control Change Event 尝试此示例jquery代码按钮或任何控件单击或控件更改事件

var url= '/Service/Grid';
$("#DivID").load(url);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM