Templating a secondary menu with linking pages - asp.net-mvc

I'm using ASP.NET MVC with Razor C# and I have implemented a main menu appearing on every page through _Layout.cshtml.
One of the pages linked to this menu opens a page that includes a secondary menu.
This page with the secondary menu links to several different pages which are navigated via the same secondary menu.
I've used Partial views to hold each secondary menu page, and I'm wondering what is the easiest/preferred way to output these partial pages via the page with the secondary menu? (Or perhaps I shouldn't even be using Partial views to save having to add the secondary menu to each page).
Thanks.

Ok, A friend, who is also working on the same problem, just showed me this: https://www.youtube.com/watch?v=SrlU8sr5Tqc
So the answer seems to be Nested Layouts.

Related

Filter data from Umbraco backoffice listview

I've a page called Page where I'll add some blocks called a PageBlock. This two are both document types. Under the Page you could create Pageblocks and Pages. Inside my listview on the backoffice, I'll only show the Pages. In the content three, I'll only show the Pages.
How could I do that?
I've tried to find a filter but nothing found and I wouldn't write a plugin. I'm using Umbraco 7.6
Update: I know how to create an listview but how could I make a filter to show only the childeren of one document type?
I don't know if I understand the question correctly, but I think what you want to do is set the permission of Pages to allow Pageblocks as its children (On the permissions tab of Pages)
Now if you want to display the children of Pages as a listview go to List view (top right) of Pages and enable Yes - Enable list view
If you want to both be able to view children in the tree and in a listview, you can leave the above option unchecked and add a List View property to the Pages documenttype (as displayed in your screenshot)

Left side is a treeview menu and right side need to be the content

I'm developing a ASP.NET MVC5 razor project and I have a cshtml divided into two parts, left part has a div with a treeview with options like a menu and the right part is a div that I would like to load cshtml that correspond to the option selected in treeview, ¿how can I do to achieve this?
Thanks
I am making the assumption that this is a simple navigation that is consistent amongst all pages, for which you can put the common navigation in the _Layout.cshtml. This file contains all the common , , tags used for each page. If you put your navigation in here then it will also be displayed on each page.
The navigation options can then link to your normal actions which display the corresponding views within the layout page.
In this tutorial the author discusses adding a simple navigation (in the section "Using a Layout for common site elements") in the _Layout with the difference that the navigation is at the top and not at the side. You can use css to style the page differently.

Umbraco 6 MVC Nav Sub Links go nowhere

I am using Umbraco 6 for MVC. My problem arises in my Navigation. It works as expected except on mobile devices. The navigation is modeled after the one seen here: http://htmlstream.com/unify/
On Mobile Devices, the dropdown sub nav links don't navigate to any other pages. When you expand a nav element with subpages and touch a sub nav link, it simply closes the dropdown.
I generate the navigation using a Razor partial view for each of the pages. It will start at the root and loop through creating a link for each visible node one level under the root. Upon reaching a node that has child nodes, the razor script will create sub nav items before moving along. This leaves me with a nice collapsible dropdown navigation that translates well to mobile devices.
The Urls for each of the nodes whether it is a main nav element or a sub nav element, are created in the foreach loop using #var.NiceUrl()
Perhaps this causes a problem but I can't figure out why all of the other links, whether on the main navigation or as buttons throughout the page, would work fine despite being created with the same .NiceUrl() method.
Anyone have any insight?
Please try to add the following code, in your style sheet:
.dropdown-backdrop
{
position: static;
}

ASP.NET MVC loading multiple partial views into a single div using JQuery

I am working on a help page which is composed of a navigation tree, content box, and search box. The navigation tree has links to Frequently Asked Questions and Glossary, each of which are linked to an Action which return partial views.
To the right of the navigation tree I have a single content div that I would like to contain whichever partial view is selected in the navigation tree.
Success case (what I want to accomplish): clicking on one of the FAQ links calls the FAQ() method in my controller, then returns a partial view which is then displayed in my content div to the right of the navigation tree. Clicking on another item would cause another partial view to be loaded.
How do I go about this? I've read a ton of ASP.NET MVC JQuery loading blog posts and tutorials but can't find anyone who's done exactly this.
Many thanks!
You should be able to use the jQuery method .load() to load HTML into your div.
http://api.jquery.com/load/
You can create an action that returns the partial view as HTML.
ASP.NET MVC Returning Partial View as a full View Page
jQuery:
one easy way you can do is load all partial views in "Container Div" at page load in one go (if performance is not a issue)
then assign each partial div with different div id inside "container", than use jquery to control show(); hide(); for each div.
MVC:
however if i were you, "Glossary" and "FAQ" looks same model to me it shouldn't be put in different partial view in first place.
if they did designed in separate model, in this scenario, i would recommend you to create a proxy class as a ViewModel above models you want to display, and then load it with one partial view only

How to build a tabbed Edit View for a big ViewModel in ASP.NET without JavaScript?

I've got a big ViewModel for a ContactViewModel with several addresses (default, invoice, delivery). This ContactViewModel I would like to edit within a DefaultAddress tab, etc. and I would like to know how to handle this without JavaScript? Is this possible?
Tell me if I'm off base here;
The way i think i'd approach this is to create a partial view which takes a list. the partial view would itterate through the list and create another partial view which is the tab.
on click of the tab i'd do a postback and store the clicked tab. this id then becomes the active tab.
when i come back to rebuild my page, the partialview for the actual tab would need to check to see if it's active and then make itself visible. if not visible then simply render nothing maybe.
This can be done with CSS. Here is an example: http://www.alistapart.com/articles/slidingdoors/
The selected tab/view will need to be rendered on the server. I can see each tab being a link, when the link is clicked the correct view and selected tab is returned.
Some of the css tabs don't work correctly in IE6. I'm not sure if the above link is one of them.

Resources