views:

591

answers:

3

how many methods for adding style sheets in a page using Asp.net MVC

A: 

Is the problem not getting the right CSS? If so, then I would check your Details.aspx file and make sure the link to the CSS is the right path. Most likely, your Details.aspx file got moved into a new subdirectory or into another directory, thus making the relative paths between the aspx file and the CSS file different.

I would check the page source from the browser and look to see what the path to the CSS file is. The way I would solve the problem would be to modify the aspx file to use a fully-qualified path to the css file. Make sure that works. Then try changing the full path to use relative path.

Tommy Hui
+1  A: 

Use absolute links to css instead of relative (eg "/Content/site.css" instead of "../Content/site.css"). Also you may use Html.Stylesheet("~/Content/site.css") extension (in MvcContrib library) to specify a stylesheet.

zihotki
A: 

Wherever you're specifying the CSS for your details page instead of a relative path e.g.

<link href="../../Content/CSS/details.css" rel="stylesheet" type="text/css" />

try using the content helper and specifying a virtual path instead

<link href="<%= Url.Content("~/Content/CSS/details.css") %>" rel="stylesheet" type="text/css" />

It seems that the site is having trouble loading getting to the CSS file based on a relative link.

sighohwell