I am new to asp.net mvc.I have gone through one video tutorial for project. In that tutorial ,inside layout view and index view instead of any html table, only div were used having bootstrap class and external css used for each div. Following classes were used.For one div more than one classes were used. Can anybody tell me meaning of these classes. 1: Active 2: Hidden 3: col-md-6
I have few queries
1 : Is it necessary to give style to element with the help of css only. If style given directly to element is also fine?
2 : For every view,will there will be each diff style sheet or one global style sheet will be there which can be used by many developer.Style sheet should not contain diff style for same class.
3 : Instead of any helper method (helper textbox method),directly html tag (input type for textbox)were used.
When to used html helper and when to used html control?
4: @Styles.Render("~/Content/css),this method was commented in layout page. I have seen this section in bundle.config file which include 2 css file on bootstrap.css and site.css and used like below
5: this link is used instead of helper method
Sachin SinghPosted Jul 12, 2021, 1:54 PM
1. Styles given directly to tag are hard to maintain, in future if you want different styling to buttons, borders, navs, etc then you will have to analyze the page carefully, which is tedious and error-prone, so external CSS is mostly preferred, apart from that it's completely up to you.
2. Yes, One global stylesheet, maintain that in the bundle. config. However, if each of the pages is completely different then there might be a different stylesheet for each view. Generally, the Layout page can handle every repetitive HTML and styling.
3. Yes, don't use Html Helpers, they are just MVC specific, if you will move to angular then pure Html will help, and will be easy to convert the views.
if there is no planning to change the UI then use Html helpers as they significantly reduce the development time.
[email protected](/content/css) means there is a bundle named css, you can directly use it in the Layout, it will dramatically increase the performance as the number of requests will be reduced. A bundle having 3 css will make a single request instead of three separate requests in case of bundling.
please, go through my article on this
https://www.sharpencode.com/article/MVC/bundling-and-minification