Summary of CSS invalidation: Chapter E of Mencius)

Source: Internet
Author: User

Some people often encounter CSS failures in ASP. NET 2.0 (ASP. NET 1.x may be valid). The main causes and solutions are listed as follows:

1. the CSS file path is incorrect.
This problem is a basic problem in Web development. Generally, this problem occurs when relative paths are used, or style files are written in the master page, this problem occurs when the content page and master page are not in the same level directory. At this point, you need to know the relative path rules in the web. If you are not clear about the rules, you can try the absolute path method to see if it is a path problem.

2. Incorrect CSS rule writing
No one can help you with this problem. You can only learn CSS-related knowledge by yourself.

3. File Encoding Problems
Sometimes, CSS styles are valid in the aspx file but not in an independent file. If this problem is not caused by path problems, it is caused by encoding problems, you can open the CSS file in notepad, and then save it as ANSI or UTF-8 format.

4. Permission issues
In this case, the style is invalid before logon and is valid only after logon. This is caused by a typical permission problem. This problem occurs only when all files configured in Web. config do not allow anonymous access. The solution is to set the <location> flag to allow anonymous access to the style file. For example:

<Configuration>
<Location Path = "folder name or file path that allows anonymous access">
<System. Web>
<Authorization>
<Allow users = "? "/>
</Authorization>
</System. Web>
</Location>
</Configuration>

 

5. click the button. The style is invalid.
The most typical cause of this situation is that a statement similar to response. Write exists in the button event. Because ASP. NET 2.0 adopts HTTP ://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtddocument definition by default, You Need To <! The front of doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> cannot have any output. The solution to this problem is to use clientscriptmanager or literal control to output content.

6. the style that works in ASP. NET 1.x is invalid in ASP. NET 2.0.
This problem is still caused by xhtml1.

7. The style set by the script is invalid.
Because the xhtml1.dtd requires a unit, you still need to add the unit when setting the value of the object style, such as obj. style. width = "200px ". The followingCodeIt is invalid in Firefox (do not complain about Firefox's troubles)

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<SCRIPT type = "text/JavaScript">
// <! [CDATA [
Function setheight ()
{
Document. getelementbyid ("X"). style. Height = "200"
}
//]>
</SCRIPT>
</Head>
<Body>
<Div id = "X" style = "Background: # DDD; Height: auto;"> test </div>
<Input type = "button" value = "set" onclick = "setheight ()"/>
</Body>
</Html>

Although the above is normal in IE, problems may occur in Firefox. The correct format is

Document. getelementbyid ("X"). style. Height = "200px"

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.