Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
JS:
$(function () {
    $("#Department").click(function () {
        $.get("/Department/Index", null, function (data) {
            $("#content").html(data);
        });
    });
});
HTML
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>

C#
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900