Creating a site from scratch, first thing to code, Master Page, header, menu or what? - asp.net

I am to create a website with ASP.net, I have the design with myself. It is a normal website
It is my first time and I do not know to start from where.
I mean what are the steps, like first menu then master page or header, footer.....
Appreciate in order way answer.

Create a prototype in HTML. No master pages, no routing, no views, controllers, inheritance. None of that.
Make a prototype of the most complex page and of the simplest page. You'll then see how to organise your layout. I'm not going to speak about architecture of the application as the topic is too broad. I assume that all this is already in place and you are asking how to build your presentation layer.
Create a basic master page that would just have a wrapper. Inherit from that master page so that you have header, main content and footer. Then adapt this to your need by introducing further inheritance if needed.
In regards to views and controllers and stuff.
I'd create those in the following way:
View model
View
Controller
Routing
This is very basic and by no means a template that will always work, but hopefully it'll give you something to think about.

Related

Example on how to reuses areas in magnolia?

I am a little bit confused. How do we reuse areas from another page? Lets say I created an article in an articles area on my index page. How do I display that same content in another page?
Ive read the following https://documentation.magnolia-cms.com/display/DOCS53/Reusing+area+content
Seems kind of complex. I dont understand the pom file.
Cant we acccomplish this purely in light modules? If not, could someone show me an example of a simple content reuse scenario?
Yes you can do it purely w/ light modules. Look at this article. Example there is custom "quotation" app and the quotes you create you can render and reuse in as many different pages/page-types you want.
However it is slightly different than what you ask. In your question you want to reuse content from the page, which is also possible (you just need to address that content and feed it to appropriate cms tag in your page template (you can forget all about maven and so on, just focus on your templates). In the example I point you to, you create custom app for stories, articles or any kind of content and then just refer it from all pages where you want to render it. This allows you not only to share the content, but also separate it's editing from the page structure which makes life of editors easier in long run.

MVC: How to create a common Section to be shared by multiple views

I am exploring the use of Sections to create optional content in my site's layout, as explained quite neatly in ScottGu's article here:
http://weblogs.asp.net/scottgu/asp-net-mvc-3-layouts-and-sections-with-razor
However, what I'm trying to do is add a sidebar to the views related to a specific controller, where the sidebar contains static information relevant to the controller. The data won't be tied to the model - it'll just be some links to external pages, and some static 'helper' text.
I don't want the Sidebar on every page / view - just on some views (in my case, it's the view related to a specific controller).
What I don't want to do is have to declare the same Section and content for each view that needs this. I was trying to find some way of creating a 'shared section' - that I could reference neatly in the views that require it, and pass back to the _Layout when the View is returned by the controller.
Partial Views seemed to be the way forward with this:
Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine
But I'm not sure if this is the right way to go about this, or if there's more succinct way to achieve what I'm aiming for.
I have been searching for answers on this, but as ever with this sort of thing, I am 100% sure I am not using the correct terminology in my search attempts for this - so apologies if this is duplicate post, basic stuff, or has already been answered elsewhere.
Any pointers on this - even if it's just to give me some direction on the terms to search on - would be welcome !
I've not provided any example code here, but could possibly knock something up if it helps articulate things.
Cheers
It sounds like you need Layout nesting, rather than sections.
You can create a master layout, then have a layout that contains the sidebar, making it's Layout property point to your master layout. Then, you can choose which layout for your content pages to use, simply by specifying Layout = Master.cshtml or Layout = Sidebar.cshtml
I think the approach outlined in the link you provided is very feasible.
Another alternative, depending on the complexity involved in getting the sidebar in your layout, you could create a separate layout.

incorporate a html-css template as master page in asp.net- mvc 4

I am building a website, and want to do it using MVC 4. I dont want to use the custom asp.net template, and the asp.net templates available online do not meet my requirements. I have designed a html-css template and need to incorporate it into my project...(pretty much build the "contents folder" of the default templated mvc 4 project myself, if u know what i mean)...
I would really appreciate if someone points me to a tutorial or gives me a step-by-step account of how to do it.
You're pretty much looking for how to use Layouts and Sections with Razor. You can have as many as you'd like.
If I'm understanding correctly, you simply want to apply your template to _Layout.cshtml. This is similar in purpose to a MasterPage in ASP.NET web forms.
Here's a ScottGu blog on layouts and sections. (Just noticed that's the same link provided by #ErikPhilips)
To provide a simple explanation. _Layout.cshtml resides at Project\Views\Shared\_Layout.cshtml. By default it looks like a normal HTML file with a couple of unusual lines. The most important being #RenderBody(). When returning a ViewResult from an action (e.g. return View("MyView, myModel)), your view gets rendered by #RenderBody inside the layout. You can do what you like with _Layout.cshtml and if you're brave, you can also nest layouts.

ASP.NET master page - control if menu html is shown or not

I'm creating an ASP.NET site where some pages need to have a div floated to the left with the site menu in and other pages don't have the menu div and instead the content takes up the entire page width.
I'm planning to use master pages - I was wondering how best to achieve this - a few immediate thoughts spring to mind:
Create 2 master pages, one with menu and one without. When creating content pages choose which master to inherit from. This is straightforward, but may require more rework if the site design changes
Create a single master page with a content placeholder for the menu. On each page include a menu div only if it is needed (seems more messy this approach)
Nested master pages?
It seems like this may be a common problem, so interested in how this is normally addressed. Note I am questioning the need for having pages without the menu - it would be simpler if all pages had exactly the same structure.
Nested master pages is probably the standard answer and should work well.
An alternative approach that occurs to me would be to put your menu in a panel control on the master page and expose a property that lets you toggle the visibility of the panel. I have not tried this yet, so I am not sure how practical it is, but it might be a fun concept to play with. If it works the way I expect this gives you a single master page that can be reconfigured by the content page.
It's up to personal preferences, but the way I was recommended was to create nested master pages,
the first master page would not contain the menu but the 2nd one would and then just point to one of the master pages.
Nested Master pages should solve your problem and also keep the Web Site scalable.
At my previous company we used two separate master pages for a similar scenario. One that included the menu and one that did not. And because they both inherited the same base master page, they both had the same functionality.
But then again, I think it comes down to personal preference.
Personally, I like the idea of having two separate pages as that way it's a bit easier to see what's going on, compared to the nested master pages.

Using a Template for Web Page

We have a fairly large public website and have recently redsigned it with a new layout. The problem now is that with our redesign we find ourselves constantly hardcoding the html layout for all of our pages. This is clearly not the best solution.
My question is what are some options on ways to share/inherit, in a sense, a web template that all our ASP.Net projects can pull from for the layout. Specifically the HTML side of the layout. Any changes made to this template will update all web sites that use it. I'm sure this exists but do not know how to approach it.
Master Pages is what you are looking for. See: http://www.asp.net/master-pages/tutorials
or http://www.asp.net/master-pages/tutorials/creating-a-site-wide-layout-using-master-pages-vb
That's the technical solution. Oftentimes, the bigger challenge in retrofitting sites that were built with numerous one-offs is determining which parts of your pages belong in the master page or content areas. Keep in mind that you can have multiple content areas and you can provide default content in a master page that can later be overriden in a content page. It's very flexible. Have fun!
The simplest approach I know is to create a header and footer file for every page. Include the header just after the <body> tag and the footer just before </body>. You content goes in between.
I prefer a more sophisticated approach with a templating system like Smarty, but that's PHP. I don't know what your ASP options are.

Resources