页面刷新时PartialView消失

页面刷新时PartialView消失

本文介绍了页面刷新时PartialView消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JS:
$(function () {
    $("#Department").click(function () {
        $.get("/Department/Index", null, function (data) {
            $("#content").html(data);
        });
    });
});
Layout Html:
   <html>
<head>
    <title></title>
    <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
script src="@Url.Content("~/JS/HumanResources.js")" type="text/javascript"></script>
    <link href= "@Url.Content("~/Content/HumanResources.css")"rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="container">
        <div id="header">
            HumanResources
        </div>
        <div id="menu">
            <div id="Department">
                Department</div>
        </div>
        <div id="mainContent">
            <div id="sidebar">
                This is the sidebar
            </div>
            <div id="content">
                @RenderBody()
            </div>
        </div>
        <div id="footer">
        </div>
    </div>
</body>
</html>


DepartmentController:
        private IEnumerable<DepartmentModel> GetDepartmentModel()
        {
            return from department in departmentRepository.GetAll().AsQueryable()
                   select new DepartmentModel
                              {
                                  ID = department.ID,
                                  Name = department.Name,
                                  Remark = department.Remark
                              };
        }
        [OutputCache(Duration=3600)]
        public PartialViewResult Index()
        {
            return PartialView(GetDepartmentModel());
        }
click Department,the data will display.Howerer,data disapper when page refresh

推荐答案




这篇关于页面刷新时PartialView消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 16:07