How do I link from one view to another when using aspnetboilerplate?


I have tried using the normal links that would work in a basic mvc project, as well as links similar to what I see in the pages the views but I seems to be getting an error that is only resolved when I add the view as a menu item on the MainMenu, which is not what I want to do. There must be a way around this...

I have a page, 'WorkOrders' (workorders/index), which displays a list of Work Orders. There's a link for creating a new work order, which should go to the 'Create' (workorders/create, I'll also need to get workorders/create/customerid working) page.

<a asp-action="Create">Create New</a>


<a href="/workorders/create">Create New</a>

both generate an error when clicked:

Unhandled exception at line 127, column 17 in 
0x800a138f - JavaScript runtime error: Unable to get property 'offsetTop' of 
undefined or null reference

Where would I define 'offsetTop'? Is there some other way to solve this error? I'm guessing that if I try to hack it away I'll just get another error to deal with and was hoping to resolve it correctly.

Does this mean it's trying to load this view inside of the shared layout that requires that value to be defined somewhere? I don't see any difference between workorders/index and workorders/create except workorders/index being on the MainMenu.

I see the pages that come with the template as examples all have their own js files, do I need to create similar js files for all of the views I add?
asked on Stack Overflow Oct 11, 2017 by Joseph Wilson • edited Oct 18, 2017 by kayess

1 Answer


You don't need to create js files for all of the views you add.

Change this in admin.js:

var activeItemOffsetTop = $('.menu .list')[0].offsetTop
if (activeItemOffsetTop > 150) $el.slimscroll({ scrollTo: activeItemOffsetTop + 'px' });

to this:

var $activeItem = $('.menu .list')[0];
if ($activeItem.length) {
    var activeItemOffsetTop = $activeItem.offsetTop;
    if (activeItemOffsetTop > 150) $el.slimscroll({ scrollTo: activeItemOffsetTop + 'px' });

This is required to handle pages without its own menu item on the main menu.

answered on Stack Overflow Oct 11, 2017 by aaron

User contributions licensed under CC BY-SA 3.0