I have a project (Web Application) that I need to implement with Web Forms. I have already prepared the design for the website and I will use one of the CSS templates that I already developed. In this case:
- Should I use a master page?
- Is there any relationship between the master page and the CSS file? If yes, how should I define master page with the CSS file?
By the way, the CSS file is a ready template.
I would highly recommend using a master page. It gives you the ability to have one consistent look across all your pages. Also if you decide to change the layout your only changing one file!
Simply reference the CSS file in your master page and it will be applied to every page the master page is used on. Something like <link href="~/styles/Style.css" rel="stylesheet" type="text/css" />
It should be noted that you can also have more then one master page. Visual studio also allows you to create pages and select the master page, it's one of the other options when adding an item.
You should have a master page if many or all of your pages share a common User Interface (such as a header, footer, navigation bar, etc).
It really doesn't matter where you put the link to the CSS file, because the CSS will be applied to the whole page either way. If the CSS is common to the entire website (or all the ones that share the same master page) put it in the Master Page. If the CSS file is page specific and you can't put it in the Master page because it conflicts with another page specific, put it in the page (in the head ContentSection).
I would suggest using master pages to control the general layout of your site, so you don't have to repeat the layout on every page. You don't need to do anything special in the CSS file to account for the master page, but you should add the link to the CSS file in the header of the master page, so it carries through to all of the pages using the master page.
Master page header:
<head runat="server">
<link rel="Stylesheet" href="~/pathtocssfile/cssfilename.css" type="text/css" />
</head>