Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 506983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:45:26+00:00 2026-05-13T06:45:26+00:00

I have an MVC masterpage set up which loads a dynamic menu using AJAX

  • 0

I have an MVC masterpage set up which loads a dynamic menu using AJAX Templates and JSON – the JSON is returned with the following call:

var tabList = []; //this holds the json data on the callback

var getTabs = function () {
    $.getJSON('Home/TabList', null, function (json) {
        Sys.Observer.clear(tabList); 
        Sys.Observer.addRange(tabList, json); 
    });
}

if (tabList == '') { getTabs(); }

So this calls a function on my HomeController to return JSON:

   public JsonResult  TabList()
    {
            //get tabs
            ... //call code to get tabs - removed for ease of reading this question
            JsonResult jsonTabs = Json(tabItems);

            jsonTabs.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            return jsonTabs;
        }
        catch (Exception ex)
        { throw ex; }

    }

This is used in the following template:
binding:

id=”tabTemplate” sys:attach=”dataview” class=”sys-template grid_16 topnav” dataview:data=”{{ tabList }}”

creating the menu items using an anchor tag:

sys:href=”{{‘/’ + Controller + ‘/’ + Action + ‘/’}}” target=”_top”

Populating the menu text using a property from the JSON object:

{{Text}}

I then attached this master page to 2 different MVC pages (“Index” and “About”, and global.asax takes me to “Index”)

So, this works great the first time I go in to the page, and the menu is drawn correctly, but when I click the About menu item which has been generated in the above template with the link “Home/About” then it stops working. What happens is that the javascript is called correctly (i.e. it calls the “getTabs” function and passes through the getJSON call) BUT it doesn’t actually hit my controller to get the JSON (I put a brekpoint on the controller action and it is not hit in this case).

I am totally at a loss and have been trying to solve this for days. Any help would be greatly appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:45:27+00:00Added an answer on May 13, 2026 at 6:45 am

    I think it may be because your .getJSON request is calling the relative path Home/TabList.

    When you are on the home page, e.g. http://localhost/, the .getJSON request will call http://localhost/Home/TabList which, as you say, works.

    BUT then when you are on a subsequent page, e.g. http://localhost/Home/About the .getJSON request will call http://localhost/Home/About/Home/TabList which, as you say, won’t work 🙂

    Anyway, try calling the absolute path /Home/TabList

    E.g.

    $.getJSON('/Home/TabList', null, function (json) {
    

    NOTE: The extra forward slash at the beginning.

    HTHs,
    Charles

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 296k
  • Answers 296k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is already possible (with a bit more noise) in… May 13, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer Referer will be the page on which the link is… May 13, 2026 at 7:03 pm
  • Editorial Team
    Editorial Team added an answer This commenter had what I was looking for (although the… May 13, 2026 at 7:03 pm

Related Questions

I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
Our ASP.NET WebForms MasterPage is making a muck of our meta data and title.
Whats the earliest point I can programatically get to the name of the masterpage
I am having trouble setting the path to jquery in an mvc app. In

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.