trying to add two css files in my MVC project
I want to include two css files for my MVC project. One for admin side and other for client side. For admin I have used shared/_Layout.cshtml file where I have added the following line of code...
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
For client side, I am trying to use Site.Master file in the Store folder, which is not in the Shared folder, where I haved added the following line of code between head...
<asp:ContentPlaceHolder ID="head" runat="server">
<link href="~/Content/Style.css"" rel="stylesheet" type="text/css" />
</asp:ContentPlaceHolder>
In my Views folder called Store/index.cshtml I have included the following line of code...
@{
<link href="@Url.Content("~/Content/Style.css")" rel="stylesheet"
type="text/css" />
}
but this is giving me a warning message... Validation (XHTML 1.0 Transitional): Element 'link' cannot be nested within element 'link'.
So my 1st question is it possible to use two css file for my MVC project? 2nd, Have I approached this the correct way? 3rd question, what shall I do about this warning message.
In for my client side I am trying to create a sidebar in the Site.Master file adding the following line of code... But nothing is happening?
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
<link href="~/Content/Style.css"" rel="stylesheet" type="text/css" />
</asp:ContentPlaceHolder>
<!-- adding the following line of code -->
<div id="header">
<div class="title">My Project</div>
</div>
<div id="categories">
Will put something useful here later
</div>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<div class="title">SPORTS STORE</div>
</asp:ContentPlaceHolder&g开发者_高级运维t;
</div>
</form>
I am using VS 2010, ASP.NET MVC 3 in C#. Thanks in advance if anyone can help me here?
Is it possible to use two css file for my MVC project?
Definitely
Have I approached this the correct way?
You're not using the proper syntax within the <link>
tag to resolve the url to your CSS file. Try using this:
<link href="<%=ResolveUrl("~/") %>Content/Style.css"
rel="stylesheet" type="text/css" />
What shall I do about this warning message?
Might be a typo, but you also have a 2 closing double quotes "". This warning message should go away if you remove this.
Found a better way. Added a new layout.cshtml file in Views/Shared path. When creating a new index.cshtml through controller, you can select the new layout.cshtml file in Razor. in MVC 3 you don't need to define Layout = "~/Views/Shared/_LayoutClient.cshtml"; in each view file. _ViewStart.cstml has been already been created for you. So you can avoid the DRY.
精彩评论