Conditional sub menus in _layout.cshml - asp.net

I am having a play with ASP.NET MVC 5 having used ASP.NET but not MVC before.
I have an entity framework powered set of controllers which return pages with that fall into two broad categories: Devices (DeviceUsage, DeviceErrors, etc.) and Stores (Stores, StoreInstallations, etc.)
I have a _layout.cshml page which lays out a page header which contains the major navigational areas of the website (Stores and Devices). What I would like is the second layer of navigation that shows only the pages within that category, that is, when viewing any of DeviceUsage, DeviceErrors etc, only these options appear in the sub menu.
What is the easiest/best/standard way of doing this?

Create a section so you can add dynamic content there. You may want to use other razor functions like #Html.Action or #Html.RenderAction.
Here is a tutorial for sections if you need.

Related

Orbeon Forms 2017 - how to make sections into tabbed pages

How does one turn a collection of Sections on an Orbeon form into page tabs. Its similar to the wizard view, except the tabs run across the top of the page and they don't assume a page workflow.
The intent would be to use Forms Builder to implement a UI in a web application, vs being a regular data collection capture form.
As of this writing, showing the "tabs" at the top of the page, rather the left side, isn't supported out-of-the-box, and this is tracked as request for enhancement 3033.
As a side note, I have seen people do this, I imagine with CSS, but suspect it isn't just a matter of adding a few rules, and requires some work.

trouble with creating a breadcrumb in asp classic

I need advice on how to do breadcrumbs in asp classic
I have a company detail page - the thing is it could have been gotten to by a number of ways - through a area or through a list of categories and then companies
I want to show the breadcrumb that this user came to it
(and the same page can be gotten to in many ways)
I tried to build a session variable but if a user clicks the back key then it messed it up
any ideas?
When you design your site you need to work out, in your own mind (best to use a pencil and paper), just how the site links together and which pages can be considered to be related. I know this sounds pretty grey, but this is more a design principal than set in stone.
Word is a good tool to work this out. Flick into Outline View and use this to build up the structure. The arrows on the ribbon at the top left allow you to indent and outdent your structure, and the markers at the beginning of the line allow you to drag and drop sections from one place to another.
Once you're happy about the structure you can update your pages to contain the stepped breadcrumb. Unless you have heavily automated pages that change their structure vastly, or a site that is very fluid (changing it's structure frequently), I would simply hard code the breadcrumb in using an unordered list (<ul>).
It gets more complicated for Classic ASP if you want to be able to automate the breadcrumb. Firstly you'd need to decide what type of automation you want to use; for instance XML, like the .NET version, or a global.asa string/array version, or something that's read from your database... The list goes on.
If you still find it difficult to get around the user's landing page train of thought, try using the search page on a site like the NHS Data Dictionary, or even try navigating using the links on the left. The breadcrumb for this site is in the top banner - watch what happens when you switch between different links.
Hope this helps, but remember there's no right or wrong way to code up your links, it simply depends on the application or site you're creating.

How to show a list over several pages

I am using Asp.NET MVC4 with Razor.
I want to show a list of items/entries (coming from a database) over several pages where the user can navigate to the next page or a specific page and each page shows e.g. 30 entries. It should be similar to the way the questions are structured in stackoverflow with this little page navigator at the bottom. How would I do that? I would guess that an example already exists but I have not found any.
Right now I show all my items on one page using a partial view in my index-view:
#foreach (var item in Model) {
#Html.Partial("_ItemInList",item)
I could probably only show the first 30 items but how do I store on which page I am and make the links so that the user can navigate to the other pages?
You could use a pagination control. There are many such components. For example you may take a look at MvcPaging hosted on GitHub.
There's an awful lot of ready made pagination controls available if you're looking for a quick result... but you're probably better off rolling your own. You can restrict your result set to a given page size in your data access layer using Linq and populate your model with single page (plus totals, page number etc...).
Depending on how you've structured your application though, you may want to push paging down to the database level and limit the result set size there rather than higher up the stack.

ASP.NET master page vs. SharePoint page layout template

A client of mine uses SharePoint to manage its websites, and recently asked me to build a small website for them using ASP.NET, which they would then implement via SharePoint.
My skills with ASP.NET are intermediate, and I have no experience at all with SharePoint.
I created a master page for the site, as well as the individual pages, but the client is telling me that they also need a page layout template in order to view and manage the site via SharePoint.
Unfortunately I have no idea what this means. So, my questions are:
What is the difference between a master page and a page template?
What does this page template look like? In other words, what type of file is it, and what kind of code goes in it?
Thanks in advance for any help you can provide!
The masterpage is what defines the design of your site. It applies for all pages within that site, except for the application pages which are shared by all SharePoint sites in the farm and use a different master page. You can recognize the application pages by looking at the url... it contains /_layouts/ (a virtual directory shared by all SharePoint sites).
When you create a new page in a MOSS site that has the publishing feature enabled, you are asked to specify a page layout. For example: 'Article page with image on right'. Each page layout is bound to one content type, in this example the content type 'Article'. Each content type can have multiple page layouts bound to it. You can have an article with the image on the right, with the image on the left or even without an image.
The content type is what defines the metadata for the page. An article for example, has a title, description, page image, article date,...
The page layouts are stored in the Master Page Gallery. You can create page layouts for existing content types, or you can create a new content type.
Basically, the master page defines how your site looks like, the page layouts define how your pages look like. One way (the easiest way) to create page layouts is to use SharePoint Designer which you can download for free from the Microsoft download pages.
You can find a lot of information about creating page layouts on the web. This may be a good starting point: http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-publishing-page-layout-HA010174128.aspx

Making a static ASP.NET site which has 100+ pages

I am converting an old html based website to ASP.NET, so that we can include more features like AJAX, Databases later on to the site. Currently my task is to create a new .aspx page for each older html page. To keep the layout persistent i have made a master page.
So currently i am building a content page from the master page, then renaming the content page and adding the text from the html page to the content placeholder area. However i was wondering if can cannot write a system, which can act as a Page Thrower.
Each hyperlink when clicked goes to a serverside code, where it requests the page it wants to load. Typically a webserver expects that the pagelink specified in the hyperlink does exist physically, but here what i am trying to do is that. Say the link is for the page "TravelDetails", the page need not exist physically, but the content of it is present in a file in (html format). so the Page Thrower gathers the data to display for that page, it has a master page already, it adds the html of it there and then throws the custom page. This way i don't have to keep 100+ aspx pages, i can do with a single page and maintain another data structure to store the content (static data) for each page. any guidance if my approach is right, and how to go about it?
Thanks
I think you should try some cms avaialable in market like dotnetnuke. Because every time you need to have to create a web page for a html page. In future if there will be any changes then it will take time. While in cms like dotnetnuke you just need to paste your html in existing system. You don't need to do coding again.
DotNetNuke is a free one. There are other Content Management System also available as well. Another advantage is that dotnetnuke is having skin features. So if you change skin at one place. You need not to do it for all the places.
Take a look at ASP.NET MVC. It uses ASP.NET Routing, which may help you.
Alternatively you can use ASP.NET Routing without MVC, too.
Matthias
Just a thought.
Create a page linked to the Master Page. In the content place holder add a Panel.
Let your Page thrower decide which page to display, retrieve the html data & add it to the panel at runtime.
Why don't you create the pages dynamically and then use asp.net caching in order to increase throughput.

Resources