瑾冰

MVC母版页异步加载子页面

电脑版发表于:2019/10/29 9:13

1:用ajax的方式实现异步加载子页面:

function MasterPageJump(Url) {
            $.ajax({
                url: Url,
                type: "GET",
                success: function (response) {
                    $('#mainContent').html(response);
                }
            });
       }  
把跳转路径传入Url中就可以了


2:母版页再加一个Id

<div id="main">
     @RenderBody()
</div>



3:子页面
  1. @{

    1. ViewBag.Title = "子页面";

    2. Layout = Request.IsAjaxRequest() ? null : "~/Views/MasterPage.cshtml";

   }

关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢