views:

324

answers:

5

Style sheet in master page is not working for one web page of asp.net application but it works for another web page.

A: 

Are none of its style elements being included? Is it being over ridden( they are Cascading Style Sheets)? Does it have the correct CSS include statement?

Paxic
A: 

Are your pages in different levels of folders ?

For example,

..\main.css

..\folder1\MasterPage.master

..\folder1\css_working.aspx

..\folder1\folder2\css_not_working.aspx

in this scenario you should define your css in masterpage as :

<link rel="stylesheet" type="text/css" href="../main.css" />

And take your pages to same level, like that :

..\main.css

..\folder1\MasterPage.master

..\folder1\css_working.aspx

..\folder2\css_not_working.aspx

Canavar
A: 

If you are using update panels there are some cases where the styling may be lost for AJAX toolkit controls. To fix this you need to put hte full name of hte class items into the stylesheet instead of letting hte toolkit handle this.

Also be sure to use a relative url where possible so that if a file moves it won't loose it's mapping.

Middletone
A: 

Use Firebug or Debug Bar, these tools will show you all the styles being employed on each element, so you can see what stylesheets it is using and which ones it is not.

Also, when you build check for any warnings about stylesheets that it can't reference etc.

TJB
+1  A: 

If you are referencing a css file from a master page you should ensure it has an absolute path, that way it will work everywhere. For example:

<head runat="server">
    <link type="text/css" rel="stylesheet" href="~/_styles/mystylesheet.css" />
</head>

The important thing to note here is that the head tag has the runar="server" attribute and that i am specifying the full virtual path using a tilde ("~").

codemonkeh