Refresh only content bar on master page when navigating asp.net mvc page

I have a master page with header, menu, content and footer panels in my asp.net mvc application (C #).

I don't want the header and footer bars to update on every page navigation, only the menu and content updates need to update.

How can I achieve this in an asp.net mvc application? any suggestions

+2


source to share


2 answers


Pure ajax loading within pages can be achieved by capturing link clicks in the navigation to something like:

$('a:not(.external)').each(function(){
  $(this).attr('href', '#'+this.href);
});

      



Then you can use the jQuery BBQ plugin to control your back button and page load using onHashChange '. This will allow you to ajax each of the main parts of the page (probably with a type call $('#main-div').load(url);

). The demo for BBQ does pretty much exactly what you would like it to, with the added benefit of not messing up the back button, so I would suggest taking a closer look at this.

+2


source


Make Ajax calls to the controller as shown below and create the "* .ascx" PartialView that you need



    $('#divMainContent').load("./LoadMainContent");



    [Authorize]
    public ActionResult LoadMainContent()
    {
        return PartialView("MainContent", sp);

    }

      

0


source







All Articles