The main layout that I want to use for all views is connected inside _ViewStart. But I would like to use second layout for some views. How can I do this?
A page can have only one layout. From your description, I think you can just combine the two layouts as a new layout, then use it for some views.
In addition, I think Partial View can also meet your needs, you can have a reference.
Related
I'm actually working on a responsive Website (with Wordpress). For responsiveness I usually use Bootstrap's grid, but this time the design mockup is completely different for the 2 views so there's no really good way to use Bootstrap here.
I was thinking of using display:none rule to switch view.
But my concern is: is it a good practice to do it because everything will be download twice for Mobile and Desktop view. If not: is there another way to do it?
Take a look at the visibility classes that bootstrap has.
The table below is the best overview how it works.
https://v4-alpha.getbootstrap.com/layout/responsive-utilities/
Though its not recommended and consider as bad practice to use display none. But mostly try to avoid it. If possible, you can use media queries to adjust the styling for mobile views.
I created a layout like this using tables, but how would I do this using only CSS and div tags? I have been trying to search the web for the past hour, and have not gotten anywhere. Could anyone point me in the right direction? How would I start coding this?
I drew up a little example of what I am trying to accomplish.
Learn a little bit about CSS layout. This isn't very difficult, but people stopped using tables for layout years ago.
You could easily do this by nesting tables and then defining their size, etc. in the css.
That said, please remember:
Note: Tables should not be used for page layout! Historically, some Web authors have misused tables in HTML as a way to control their page layout. However, there are a variety of alternatives to using HTML tables for layout, primarily using CSS.
In other words, this would be really bad practice unless it's for a class assignment.
You can use div elements. Use CSS to add width to achieve the desired layout.
knows anyone an article I can implement a template-system in my ASP.NET MVC 4 application?
Like many other websites, my own has many different categories and for each should use there own template.
The color circle is the template (like musictemplate_layout.cshtml) and ContentPlaceHolder123 has always the same content.
Best regards,
Patrik
Create different Views as your specific templates like bellow:
Use different layouts by defining at the top of each page like bellow:
#{
Layout = "~/Views/Shared/Layout1.cshtml";
}
Also, you can have more levels of Layouts, according to your interface plans. You can use layouts dynamically by different factors, like UserAgent or ... by Placing string variable in front of 'Layout' for more adoptable or intelligent results.
I am generating HTML tables based on SQL statements for a Datawarehouse created through meta table information.
One of the issues I have is some of returned Datatables have 100 plus columns. Is there a neat way of displaying this in an HTML table or a specific design solution. Please note I am looking at the display here. Changing the amount of columns available is not an option. All columns need to be rendered.
Many thanks in advance for input.
I can think of 2 good solutions:
Wrap the whole table with a fixed-width container, and set overflow-x: auto on it. That will cause the table to scroll.
Allow the user to filter out whichever columns he doesn't need to see using JavaScript/jQuery.
Both are possible, the first is obviously easier to implement, but with the second you have more control. Choose your path and if you're stuck, you can ask here on StackOverflow for help.
What you are describing is called datagrid. You definitely should not generate the HTML yourself(as you sad) and instead just bind the result set to any kind of server-side data-grid or use some kind of client-side jQuery datagrid implementation.
https://stackoverflow.com/questions/159025/jquery-grid-recommendations
The Details template of MVC 3 returned a view use <fieldset> to display elements that represent all fields in one column. But I need to show elements or fields of a model in two or more columns. Is there any good template for this? what is your suggestion?
There's nothing specific about MVC here. This is just plain old html and css. I suggest getting a good book on HTML and CSS, and these sorts of things will be clear to you.
One of many many many ways you could do it:
http://www.gethifi.com/blog/html-forms-the-right-ways
One option you have is using editor templates for MVC, which allow you to take control of the how html rendering for a model is generated. Here's a blog post with an example
Using EditorTemplates in MVC 3
What you are looking for is modifying the Scaffolding Template that generated that view.
Or other option could be doing that manually, checking the best way to "display" each of your models.