views:

37

answers:

2

Using C#

In my webpage style sheet is not loading, i am using Google Chrome Browser

Code.

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
<title>Data Entry</title>
<link rel="stylesheet" href="G:/style.css" type="text/css" charset="utf-8" />
</head>
</html>

The above code is not loading the style.css file.

How to solve this issue.

A: 

if it has to be on the file system:

href="file:///g:/style.css"

If your stylesheet is in the same folder as Default.aspx, use

<link rel="stylesheet" href="/style.css" type="text/css" charset="utf-8" />

In this case, the leading slash '/' is important because it points to the root of the domain, so if you page url is http://localhost:8000/folder/anotherfolder/page.aspx, then the href="/style.css" will still point to http://localhost:8000/style.css, not http://localhost:8000/folder/anotherfolder/style.css. This means that all of your pages will point to the same stylesheet in the same place.

If your stylesheet is in a sub folder of the application root such as css/, use

<link rel="stylesheet" href="/css/style.css" type="text/css" charset="utf-8" />

If it really is in G:/, copy it to the root of your application and use the first example above.

Daniel Dyson
+3  A: 

Your HREF is incorrect:

href="G:/style.css"

You need to either use a relative path:

href="../style.css"

Or if you must use a file URI, use the correct one - this will mean only people with the correct browser/operating system and with G drive can see the stylesheet:

href="file:///g:/style.css"
Oded
Second one is not working(file:///g|/style.css), my stylesheet is located in G Drive, how to load the style sheet?
Gopal
See my answer: href="file:///g:/style.css"
Daniel Dyson
@Gopal - follow the link I posted about [`fileURI`](http://en.wikipedia.org/wiki/File_URI_scheme) to see what you could use.
Oded